Permalink
Browse files

PEP8 compliant import

  • Loading branch information...
1 parent 2ef32ec commit c3c48e01eb0ef516eb73de8f8e428af8ba1cdc1c @RogueM RogueM committed Sep 13, 2016
Showing with 77 additions and 35 deletions.
  1. +3 −2 convert.py
  2. +23 −17 generate-html.py
  3. +10 −3 generate-json.py
  4. +10 −2 markjaml.py
  5. +6 −1 pinout.py
  6. +8 −1 serve.py
  7. +10 −4 tools/generate-defines.py
  8. +7 −5 urlmapper.py
View
@@ -1,4 +1,6 @@
-import json, sys
+import json
+import sys
+
db = json.load(open('pi-pinout.db'))
@@ -27,4 +29,3 @@ def to_phys(pin, mode="bcm"):
mode = sys.argv[2]
print("Pin {} is {}: {}".format(pin, mode.upper(), from_phys(pin, mode)))
-
View
@@ -1,13 +1,20 @@
#!/usr/bin/env python
-import markdown
-import unicodedata
-import re
+
import os
+import re
import sys
-import pinout
+import unicodedata
+
+try:
+ import markdown
+except ImportError:
+ exit("This script requires the psutil module\nInstall with: sudo pip install Markdown")
+
import markjaml
+import pinout
import urlmapper
+
reload(sys)
sys.setdefaultencoding('utf8')
@@ -44,7 +51,6 @@
}
-
def cssify(value):
value = slugify(value);
if value[0] == '3' or value[0] == '5':
@@ -246,17 +252,17 @@ def render_pin_page(pin_num):
fn_functions.append(function)
pin_functions = '''<table class="pin-functions">
- <thead>
- <tr>
- <th>{headings}</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>{functions}</td>
- </tr>
- </tbody>
- </table>'''.format(headings='</th><th>'.join(fn_headings), functions='</td><td>'.join(fn_functions))
+ <thead>
+ <tr>
+ <th>{headings}</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{functions}</td>
+ </tr>
+ </tbody>
+ </table>'''.format(headings='</th><th>'.join(fn_headings), functions='</td><td>'.join(fn_functions))
pin_url = slugify('pin{}_{}'.format(pin_num, pin_url))
@@ -270,7 +276,7 @@ def render_pin_page(pin_num):
# if pin_text != None:
return pin_url, pin_text, pin_text_name # pages[pin_url] = pin_text
-
+
def render_pin(pin_num, selected_url, overlay=None):
pin = pinout.pins[str(pin_num)]
View
@@ -1,11 +1,18 @@
#!/usr/bin/env python
+
import json
-import markdown
-import unicodedata
import re
import sys
-import pinout
+import unicodedata
+
+try:
+ import markdown
+except ImportError:
+ exit("This script requires the psutil module\nInstall with: sudo pip install Markdown")
+
import markjaml
+import pinout
+
reload(sys)
sys.setdefaultencoding('utf8')
View
@@ -1,9 +1,17 @@
import json
-import markdown
-import yaml
import re
import unicodedata
+try:
+ import markdown
+except ImportError:
+ exit("This script requires the psutil module\nInstall with: sudo pip install Markdown")
+
+try:
+ import yaml
+except ImportError:
+ exit("This script requires the psutil module\nInstall with: sudo pip install PyYAML")
+
def slugify(value):
"""
View
@@ -1,7 +1,12 @@
import json
-import yaml
import time
+try:
+ import yaml
+except ImportError:
+ exit("This script requires the psutil module\nInstall with: sudo pip install PyYAML")
+
+
DB_FILE = 'pi-pinout.yaml'
SETTINGS_FILE = 'settings.yaml'
View
@@ -1,6 +1,13 @@
#!/usr/bin/env python
-from flask import Flask, send_from_directory
+
import sys
+
+try:
+ from flask import Flask, send_from_directory
+except ImportError:
+ exit("This script requires the psutil module\nInstall with: sudo pip install Flask")
+
+
app = Flask(__name__)
lang = 'en'
@@ -1,11 +1,17 @@
#!/usr/bin/env python
+
import json
-import markdown
-import unicodedata
-import re
import os
-import time
+import re
import sys
+import time
+import unicodedata
+
+try:
+ import markdown
+except ImportError:
+ exit("This script requires the psutil module\nInstall with: sudo pip install Markdown")
+
lang = 'en'
View
@@ -1,11 +1,14 @@
#!/usr/bin/env python
-import unicodedata
+
+import glob
+import os
import re
import sys
-import pinout
+import unicodedata
+
import markjaml
-import glob
-import os
+import pinout
+
reload(sys)
sys.setdefaultencoding('utf8')
@@ -91,4 +94,3 @@ def generate_urls(lang="en"):
for lang in languages:
urls[lang] = generate_for_lang(lang)
return urls
-

0 comments on commit c3c48e0

Please sign in to comment.