예제 #1
0
def generate_for_lang(lang="en"):
    url_lookup = {}

    pinout.load(lang)

    overlays = pinout.settings['overlays']

    base_url = pinout.get_setting('base_url', '/pinout/')

    domain = pinout.get_setting('domain', 'pinout.xyz')

    overlays_html = ''

    overlays = map(lambda overlay: load_overlay_url(overlay, lang), overlays)

    for pin in range(1, len(pinout.pins) + 1):
        pin_url = get_pin_url(pin, pinout)
        if pin_url is None:
            continue

        url_lookup['pin{}'.format(pin)] = '//{domain}{base_url}{url}'.format(
            domain=domain, base_url=base_url, url=pin_url)

    for url in overlays:
        if url is None:
            continue

        url_lookup['{}'.format(url[0])] = '//{domain}{base_url}{url}'.format(
            domain=domain, base_url=base_url, url=url[1])

    url_lookup['index'] = '//{}'.format(domain)

    return url_lookup
예제 #2
0
def generate_for_lang(lang="en"):
    url_lookup = {}

    pinout.load(lang)

    overlays = pinout.settings['overlays']

    base_url = pinout.get_setting('base_url', '/pinout/')

    domain = pinout.get_setting('domain', 'pinout.xyz')

    overlays_html = ''

    overlays = map(lambda overlay: load_overlay_url(overlay, lang), overlays)

    for pin in range(1, len(pinout.pins)+1):
        pin_url = get_pin_url(pin, pinout)
        if pin_url is None:
            continue

        url_lookup['pin{}'.format(pin)] = '//{domain}{base_url}{url}'.format(domain=domain, base_url=base_url, url=pin_url)

    for url in overlays:
        if url is None:
            continue

        url_lookup['{}'.format(url[0])] = '//{domain}{base_url}{url}'.format(domain=domain, base_url=base_url, url=url[1])


    url_lookup['index'] = '//{}'.format(domain)

    return url_lookup
예제 #3
0
def generate_for_lang(lang="en"):
    url_lookup = {}

    pinout.load(lang)

    overlays = pinout.settings["overlays"]

    base_url = pinout.get_setting("base_url", "/pinout/")

    domain = pinout.get_setting("domain", "pinout.xyz")

    overlays_html = ""

    overlays = map(lambda overlay: load_overlay_url(overlay, lang), overlays)

    for pin in range(1, len(pinout.pins) + 1):
        pin_url = get_pin_url(pin, pinout)
        if pin_url is None:
            continue

        url_lookup["pin{}".format(pin)] = "//{domain}{base_url}{url}".format(
            domain=domain, base_url=base_url, url=pin_url
        )

    for url in overlays:
        if url is None:
            continue

        url_lookup["{}".format(url[0])] = "//{domain}{base_url}{url}".format(
            domain=domain, base_url=base_url, url=url[1]
        )

    url_lookup["index"] = "//{}".format(domain)

    return url_lookup
예제 #4
0
def generate_for_lang(lang="en"):
    url_lookup = {}

    pinout.load(lang)

    overlays = glob.glob("src/{}/overlay/*.md".format(lang)) + glob.glob(
        "src/{}/translate/*.md".format(lang))
    overlays = [
        overlay.split("/")[-1].replace(".md", "") for overlay in overlays
    ]

    base_url = pinout.get_setting('base_url', '/pinout/')

    domain = pinout.get_setting('domain', 'pinout.xyz')

    overlays_html = ''

    overlays = map(lambda overlay: load_overlay_url(overlay, lang), overlays)

    for pin in range(1, len(pinout.pins) + 1):
        pin_url = get_pin_url(pin, pinout)
        if pin_url is None:
            continue

        url_lookup['pin{}'.format(pin)] = '//{domain}{base_url}{url}'.format(
            domain=domain, base_url=base_url, url=pin_url)

    for url in overlays:
        if url is None:
            continue

        url_lookup['{}'.format(url[0])] = '//{domain}{base_url}{url}'.format(
            domain=domain, base_url=base_url, url=url[1])

    url_lookup['index'] = '//{}'.format(domain)

    url_lookup['boards'] = '//{}/boards'.format(domain)

    return url_lookup
예제 #5
0
def render_pin(pin_num, selected_url, overlay=None):
    pin = pinout.pins[str(pin_num)]

    pin_type = list([x.strip() for x in pin['type'].lower().split('/')])
    pin_url = pin['name']
    pin_name = pin['name']
    pin_used = False
    pin_link_title = []
    bcm_pin = None
    if 'scheme' in pin:
        if 'bcm' in pin['scheme']:
            bcm_pin = 'bcm' + str(pin['scheme']['bcm'])

    if overlay is not None and (
                        pin_num in overlay['pin'] or str(pin_num) in overlay['pin'] or bcm_pin in overlay['pin']):

        if pin_num in overlay['pin']:
            overlay_pin = overlay['pin'][pin_num]
        elif str(pin_num) in overlay['pin']:
            overlay_pin = overlay['pin'][str(pin_num)]
        else:
            overlay_pin = overlay['pin'][bcm_pin]

        if overlay_pin is None:
            overlay_pin = {}

        pin_used = True

        if 'name' in overlay_pin:
            pin_name = overlay_pin['name']

        if 'description' in overlay_pin:
            pin_link_title.append(overlay_pin['description'])

    if 'scheme' in pin:
        if 'bcm' in pin['scheme']:
            bcm = pin['scheme']['bcm']
            pin_subname = ''

            pin_url = 'gpio{}'.format(bcm)
            if pin_name != '':
                pin_subname = '<small>({})</small>'.format(pin_name)
            pin_name = 'BCM {} {}'.format(bcm, pin_subname)
        if 'wiringpi' in pin['scheme']:
            wiringpi = pin['scheme']['wiringpi']
            pin_link_title.append(strings['wiring_pi_pin'].format(wiringpi))

    pin_url = base_url + slugify('pin{}_{}'.format(pin_num, pin_url))

    if pin['type'] in pinout.get_setting('urls'):
        pin_url = base_url + pinout.get_setting('urls')[pin['type']]

    selected = ''

    if base_url + selected_url == pin_url:
        selected = ' active'
    if pin_used:
        selected += ' overlay-pin'

    pin_url = pin_url + url_suffix

    return '<li class="pin{pin_num} {pin_type}{pin_selected}"><a href="{pin_url}" title="{pin_title}"><span class="default"><span class="phys">{pin_num}</span> {pin_name}</span><span class="pin"></span></a></li>\n'.format(
        pin_num=pin_num,
        pin_type=' '.join(map(cssify, pin_type)),
        pin_selected=selected,
        pin_url=pin_url,
        pin_title=', '.join(pin_link_title),
        pin_name=pin_name,
        langcode=lang
    )
예제 #6
0

'''
Main Program Flow
'''

if len(sys.argv) > 1:
    lang = sys.argv[1]

alternate_urls = urlmapper.generate_urls(lang)

pinout.load(lang)

overlays = pinout.settings['overlays']

strings = pinout.get_setting('strings', {})

if type(strings) == list:
    _strings = {}
    for item in strings:
        _strings[item.keys()[0]] = item.values()[0]
    strings = _strings

for key, val in default_strings.items():
    if key not in strings:
        strings[key] = val

base_url = pinout.get_setting('base_url', '/pinout/')  # '/pinout-tr/pinout/'
resource_url = pinout.get_setting('resource_url', '/resources/')  # '/pinout-tr/resources/'
url_suffix = pinout.get_setting('url_suffix', '')  # '.html'
예제 #7
0
def render_pin(pin_num, selected_url, overlay=None):
    pin = pinout.pins[str(pin_num)]

    pin_type = list([x.strip() for x in pin['type'].lower().split('/')])
    pin_url = pin['name']
    pin_name = pin['name']
    pin_ground = False
    pin_power = False
    pin_regular = False
    pin_link_title = []
    bcm_pin = None

    if overlay is not None and 'ground' in overlay and (
            pin_num in overlay['ground'] or str(pin_num) in overlay['ground']):

        if pin_num in overlay['ground']:
            overlay_pin = overlay['ground'][pin_num]
        else:
            overlay_pin = overlay['ground'][str(pin_num)]

        if overlay_pin is None:
            overlay_pin = {}

        pin_ground = True

    if overlay is not None and 'power' in overlay and (
            pin_num in overlay['power'] or str(pin_num) in overlay['power']):

        if pin_num in overlay['power']:
            overlay_pin = overlay['power'][pin_num]
        else:
            overlay_pin = overlay['power'][str(pin_num)]

        if overlay_pin is None:
            overlay_pin = {}

        pin_power = True

    if 'scheme' in pin:
        if 'bcm' in pin['scheme']:
            bcm_pin = 'bcm' + str(pin['scheme']['bcm'])

    if overlay is not None and 'pin' in overlay and (
            pin_num in overlay['pin'] or str(pin_num) in overlay['pin']
            or bcm_pin in overlay['pin']):

        if pin_num in overlay['pin']:
            overlay_pin = overlay['pin'][pin_num]
        elif str(pin_num) in overlay['pin']:
            overlay_pin = overlay['pin'][str(pin_num)]
        else:
            overlay_pin = overlay['pin'][bcm_pin]

        if overlay_pin is None:
            overlay_pin = {}

        pin_regular = True

        if 'name' in overlay_pin:
            pin_name = overlay_pin['name']

        if 'description' in overlay_pin:
            pin_link_title.append(overlay_pin['description'])

    if 'scheme' in pin:
        if 'bcm' in pin['scheme']:
            bcm = pin['scheme']['bcm']
            pin_subname = ''

            pin_url = 'gpio{}'.format(bcm)
            if pin_name != '':
                pin_subname = '<small>({})</small>'.format(pin_name)
            pin_name = 'BCM {} {}'.format(bcm, pin_subname)
        if 'wiringpi' in pin['scheme']:
            wiringpi = pin['scheme']['wiringpi']
            pin_link_title.append(strings['wiring_pi_pin'].format(wiringpi))

    pin_url = base_url + slugify('pin{}_{}'.format(pin_num, pin_url))

    if pin['type'] in pinout.get_setting('urls'):
        pin_url = base_url + pinout.get_setting('urls')[pin['type']]

    selected = ''

    if base_url + selected_url == pin_url:
        selected = ' active'
    if pin_ground:
        selected += ' overlay-ground'
    if pin_power:
        selected += ' overlay-power'
    if pin_regular:
        selected += ' overlay-pin'

    pin_url = pin_url + url_suffix

    return '<li class="pin{pin_num} {pin_type}{pin_selected}"><a href="{pin_url}.html" title="{pin_title}"><span class="default"><span class="phys">{pin_num}</span> {pin_name}</span><span class="pin"></span></a></li>\n'.format(
        pin_num=pin_num,
        pin_type=' '.join(map(cssify, pin_type)),
        pin_selected=selected,
        pin_url=pin_url,
        pin_title=', '.join(pin_link_title),
        pin_name=pin_name,
        langcode=lang)
예제 #8
0
overlays = pinout.settings['overlays']

strings = pinout.get_string('strings', {})

if type(strings) == list:
    _strings = {}
    for item in strings:
        _strings[item.keys()[0]] = item.values()[0]
    strings = _strings

for key, val in default_strings.items():
    if key not in strings:
        strings[key] = val

base_url = pinout.get_setting('base_url', '/pinout/')  # '/pinout-tr/pinout/'
resource_url = pinout.get_setting(
    'resource_url', '/pinout/resources/')  # '/pinout-tr/resources/'
url_suffix = pinout.get_setting('url_suffix', '')  # '.html'

template_main = open('common/page.html'.format(lang)).read()
template_boards = open('common/boards.html'.format(lang)).read()
template_footer = open('src/{}/template/footer.html'.format(lang)).read()
template_footer = open('src/{}/template/footer.html'.format(lang)).read()

pages = {}
navs = {}

overlays_html = []

nav_html = {}
예제 #9
0
def render_pin(pin_num, selected_url, overlay=None):
    pin = pinout.pins[str(pin_num)]

    pin_type = list([x.strip() for x in pin['type'].lower().split('/')])
    pin_name = pin['name']
    pin_url = pin_name
    pin_ground = False
    pin_power = False
    pin_regular = False
    pin_link_title = []
    bcm_pin = None
    overlay_pin = {}

    if 'scheme' in pin:
        if 'bcm' in pin['scheme']:
            bcm_pin = 'bcm' + str(pin['scheme']['bcm'])

    valid_pins = (pin_num, str(pin_num), bcm_pin)

    if overlay is not None:
        for try_pin in valid_pins:
            if try_pin in overlay.get('ground', {}):
                overlay_pin = overlay['ground'][try_pin]
                pin_ground = True
                break
            if try_pin in overlay.get('power', {}):
                overlay_pin = overlay['power'][try_pin]
                pin_power = True
                break
            if try_pin in overlay.get('pin', {}):
                overlay_pin = overlay['pin'][try_pin]
                pin_regular = True
                break

        if isinstance(overlay_pin, str):
            # source = ''
            # if 'source' in overlay:
            #     source = overlay['source']
            # TODO: What is this?
            debug(
                1,
                "{}: Overlay pin '{}' for pin {} is a string! Should be dict".
                format(overlay['source'], overlay_pin, pin_num))

        if overlay_pin is None:
            overlay_pin = {}

        if pin_regular:
            pin_name = overlay_pin.get('name', pin_name)

            if 'description' in overlay_pin:
                pin_link_title.append(overlay_pin['description'])

            if overlay_pin.get('mode') == "EEPROM_WP":
                pin_name = "EEPROM WP"

    if 'scheme' in pin:
        if 'bcm' in pin['scheme']:
            bcm = pin['scheme']['bcm']
            pin_subname = ''

            pin_url = 'gpio{}'.format(bcm)
            if pin_name != '':
                pin_subname = ' <small>({})</small>'.format(pin_name)
            pin_name = '<span class="name">GPIO {}</span>{}'.format(
                bcm, pin_subname)

        if 'wiringpi' in pin['scheme']:
            wiringpi = pin['scheme']['wiringpi']
            pin_link_title.append(strings['wiring_pi_pin'].format(wiringpi))

    pin_url = base_url + slugify('pin{}_{}'.format(pin_num, pin_url))

    if pin['type'] in pinout.get_setting('urls'):
        pin_url = base_url + pinout.get_setting('urls')[pin['type']]

    selected = ''

    if base_url + selected_url == pin_url:
        selected = ' active'
    if pin_ground:
        selected += ' overlay-ground'
    if pin_power:
        selected += ' overlay-power'
    if pin_regular:
        selected += ' overlay-pin'

    pin_url = pin_url + url_suffix

    return '<li class="pin{pin_num} {pin_type}{pin_selected}"><a href="{pin_url}" title="{pin_title}"><span class="default"><span class="phys">{pin_num}</span> {pin_name}</span><span class="pin"></span></a></li>\n'.format(
        pin_num=pin_num,
        pin_type=' '.join(map(cssify, pin_type)),
        pin_selected=selected,
        pin_url=pin_url,
        pin_title=', '.join(pin_link_title),
        pin_name=pin_name,
        langcode=lang)