Skip to content
This repository has been archived by the owner on Jun 19, 2024. It is now read-only.

Changes made to run files of not-working folder as well as working folder #153

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 29 additions & 22 deletions gerber/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,62 +28,62 @@

hints = [
Hint(layer='top',
ext=['gtl', 'cmp', 'top', ],
name=['art01', 'top', 'GTL', 'layer1', 'soldcom', 'comp', 'F.Cu', ],
ext=['gtl', 'cmp', 'top', 'gbr', ],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'gbr' should not be added as an extension hint to any of these layer types because it is not unique to any specific layer type.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's true that 'gbr' is not the unique extension, in practice, I should not add it as hint extension.

name=['art01', 'top', 'GTL', 'layer1', 'soldcom', 'comp', 'F.Cu', "top_l", ],
regex='',
content=[]
),
Hint(layer='bottom',
ext=['gbl', 'sld', 'bot', 'sol', 'bottom', ],
name=['art02', 'bottom', 'bot', 'GBL', 'layer2', 'soldsold', 'B.Cu', ],
ext=['gbl', 'sld', 'bot', 'sol', 'bottom', 'gbr', ],
name=['art02', 'bottom', 'bot', 'GBL', 'layer2', 'soldsold', 'B.Cu', "bottom_l", ],
regex='',
content=[]
),
Hint(layer='internal',
ext=['in', 'gt1', 'gt2', 'gt3', 'gt4', 'gt5', 'gt6',
'g1', 'g2', 'g3', 'g4', 'g5', 'g6', ],
'g1', 'g2', 'g3', 'g4', 'g5', 'g6', 'gbr', ],
name=['art', 'internal', 'pgp', 'pwr', 'gnd', 'ground',
'gp1', 'gp2', 'gp3', 'gp4', 'gt5', 'gp6',
'In1.Cu', 'In2.Cu', 'In3.Cu', 'In4.Cu',
'group3', 'group4', 'group5', 'group6', 'group7', 'group8', ],
'group3', 'group4', 'group5', 'group6', 'group7', 'group8', 'inner_l1', 'inner_l2', ],
regex='',
content=[]
),
Hint(layer='topsilk',
ext=['gto', 'sst', 'plc', 'ts', 'skt', 'topsilk', ],
name=['sst01', 'topsilk', 'silk', 'slk', 'sst', 'F.SilkS'],
ext=['gto', 'sst', 'plc', 'ts', 'skt', 'topsilk', 'gbr', ],
name=['sst01', 'topsilk', 'silk', 'slk', 'sst', 'F.SilkS', 'screen_t', ],
regex='',
content=[]
),
Hint(layer='bottomsilk',
ext=['gbo', 'ssb', 'pls', 'bs', 'skb', 'bottomsilk', ],
name=['bsilk', 'ssb', 'botsilk', 'bottomsilk', 'B.SilkS'],
ext=['gbo', 'ssb', 'pls', 'bs', 'skb', 'bottomsilk', 'gbr', ],
name=['bsilk', 'ssb', 'botsilk', 'bottomsilk', 'B.SilkS', 'screen_b', ],
regex='',
content=[]
),
Hint(layer='topmask',
ext=['gts', 'stc', 'tmk', 'smt', 'tr', 'topmask', ],
ext=['gts', 'stc', 'tmk', 'smt', 'tr', 'topmask', 'gbr', ],
name=['sm01', 'cmask', 'tmask', 'mask1', 'maskcom', 'topmask',
'mst', 'F.Mask', ],
'mst', 'F.Mask', 'mask_t', ],
regex='',
content=[]
),
Hint(layer='bottommask',
ext=['gbs', 'sts', 'bmk', 'smb', 'br', 'bottommask', ],
ext=['gbs', 'sts', 'bmk', 'smb', 'br', 'bottommask', 'gbr', ],
name=['sm', 'bmask', 'mask2', 'masksold', 'botmask', 'bottommask',
'msb', 'B.Mask', ],
'msb', 'B.Mask', 'mask_b', ],
regex='',
content=[]
),
Hint(layer='toppaste',
ext=['gtp', 'tm', 'toppaste', ],
name=['sp01', 'toppaste', 'pst', 'F.Paste'],
ext=['gtp', 'tm', 'toppaste', 'gbr', ],
name=['sp01', 'toppaste', 'pst', 'F.Paste', 'paste_t', ],
regex='',
content=[]
),
Hint(layer='bottompaste',
ext=['gbp', 'bm', 'bottompaste', ],
name=['sp02', 'botpaste', 'bottompaste', 'psb', 'B.Paste', ],
ext=['gbp', 'bm', 'bottompaste', 'gbr', ],
name=['sp02', 'botpaste', 'bottompaste', 'psb', 'B.Paste', 'paste_b'],
regex='',
content=[]
),
Expand Down Expand Up @@ -125,13 +125,13 @@ def load_layer_data(data, filename=None):


def guess_layer_class(filename):

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unecessary whitespace change

try:
layer = guess_layer_class_by_content(filename)
if layer:
return layer
except:
pass

try:
directory, filename = os.path.split(filename)
name, ext = os.path.splitext(filename.lower())
Expand All @@ -140,11 +140,18 @@ def guess_layer_class(filename):
if re.findall(hint.regex, filename, re.IGNORECASE):
return hint.layer

patterns = [r'^(\w*[.-])*{}([.-]\w*)?$'.format(x) for x in hint.name]
if ext[1:] in hint.ext or any(re.findall(p, name, re.IGNORECASE) for p in patterns):
return hint.layer
if ext[1:] == 'gbr': #Prateek
patterns = [r'(\w*[.-])*{}([.-]\w*)?$'.format(x) for x in hint.name] #Prateek
if any(re.findall(p, name, re.IGNORECASE) for p in patterns): #Prateek
return hint.layer #Prateek
else : #Prateek
patterns = [r'^(\w*[.-])*{}([.-]\w*)?$'.format(x) for x in hint.name]
if ext[1:] in hint.ext or any(re.findall(p, name, re.IGNORECASE) for p in patterns):
return hint.layer

Comment on lines +143 to +151
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of these changes are necessary if you remove 'gbr' from the extension hints above

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes if I remove 'gbr' from the extension hints these changes are not required, but one change is required and that is in defining patterns :
patterns = [r'(\w*[.-]){}([.-]\w)?$'.format(x) for x in hint.name]
instead of
patterns = [r'^(\w*[.-]){}([.-]\w)?$'.format(x) for x in hint.name]
according to my changes to name attribute in hints.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is * before {} in defining patterns, i.e.;
patterns = [r'(\w*[.-]){}([.-]\w)?$'.format(x) for x in hint.name]

except:
pass

return 'unknown'


Expand Down
1 change: 1 addition & 0 deletions gerber/pcb.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def from_directory(cls, directory, board_name=None, verbose=False):
if not os.path.isdir(directory):
raise TypeError('{} is not a directory.'.format(directory))


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unecessary

# Load gerber files
for filename in listdir(directory, True, True):
try:
Expand Down