summaryrefslogtreecommitdiff
path: root/gerber/utils.py
diff options
context:
space:
mode:
authorHamilton Kibbe <hamilton.kibbe@gmail.com>2015-12-22 02:45:48 -0500
committerHamilton Kibbe <hamilton.kibbe@gmail.com>2015-12-22 02:47:23 -0500
commit6f876edd09d9b81649691e529f85653f14b8fd1c (patch)
tree808e3ea789816452f52e834d4c5c1744bdee6541 /gerber/utils.py
parentaf5541ac93b222c05229ee05c9def8dbae5f6e25 (diff)
downloadgerbonara-6f876edd09d9b81649691e529f85653f14b8fd1c.tar.gz
gerbonara-6f876edd09d9b81649691e529f85653f14b8fd1c.tar.bz2
gerbonara-6f876edd09d9b81649691e529f85653f14b8fd1c.zip
Add PCB interface
this incorporates some of @chintal's layers.py changes PCB.from_directory() simplifies loading of multiple gerbers the PCB() class should be pretty helpful going forward... the context classes could use some cleaning up, although I'd like to wait until the freecad stuff gets merged, that way we can try to refactor the context base to support more use cases
Diffstat (limited to 'gerber/utils.py')
-rw-r--r--gerber/utils.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/gerber/utils.py b/gerber/utils.py
index 1c0af52..6653683 100644
--- a/gerber/utils.py
+++ b/gerber/utils.py
@@ -26,6 +26,7 @@ files.
# Author: Hamilton Kibbe <ham@hamiltonkib.be>
# License:
+import os
from math import radians, sin, cos
from operator import sub
@@ -219,7 +220,10 @@ def detect_file_format(data):
if 'M48' in line:
return 'excellon'
elif '%FS' in line:
- return'rs274x'
+ return 'rs274x'
+ elif ((len(line.split()) >= 2) and
+ (line.split()[0] == 'P') and (line.split()[1] == 'JOB')):
+ return 'ipc_d_356'
return 'unknown'
@@ -288,3 +292,13 @@ def rotate_point(point, angle, center=(0.0, 0.0)):
x = center[0] + (cos(angle) * xdelta) - (sin(angle) * ydelta)
y = center[1] + (sin(angle) * xdelta) - (cos(angle) * ydelta)
return (x, y)
+
+
+def listdir(directory, ignore_hidden=True, ignore_os=True):
+ os_files = ('.DS_Store', 'Thumbs.db', 'ethumbs.db')
+ files = os.listdir(directory)
+ if ignore_hidden:
+ files = [f for f in files if not f.startswith('.')]
+ if ignore_os:
+ files = [f for f in files if not f in os_files]
+ return files