aboutsummaryrefslogtreecommitdiffstats
path: root/meta-python/recipes-devtools/python/python3-socketio_4.5.1.bb
AgeCommit message (Expand)Author
2020-04-03python3-socketio: upgrade 4.4.0 -> 4.5.1Pierre-Jean Texier
.k { color: #66d9ef } /* Keyword */ .highlight .l { color: #ae81ff } /* Literal */ .highlight .n { color: #f8f8f2 } /* Name */ .highlight .o { color: #f92672 } /* Operator */ .highlight .p { color: #f8f8f2 } /* Punctuation */ .highlight .ch { color: #75715e } /* Comment.Hashbang */ .highlight .cm { color: #75715e } /* Comment.Multiline */ .highlight .cp { color: #75715e } /* Comment.Preproc */ .highlight .cpf { color: #75715e } /* Comment.PreprocFile */ .highlight .c1 { color: #75715e } /* Comment.Single */ .highlight .cs { color: #75715e } /* Comment.Special */ .highlight .gd { color: #f92672 } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .gi { color: #a6e22e } /* Generic.Inserted */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #75715e } /* Generic.Subheading */ .highlight .kc { color: #66d9ef } /* Keyword.Constant */ .highlight .kd { color: #66d9ef } /* Keyword.Declaration */ .highlight .kn { color: #f92672 } /* Keyword.Namespace */ .highlight .kp { color: #66d9ef } /* Keyword.Pseudo */ .highlight .kr { color: #66d9ef } /* Keyword.Reserved */ .highlight .kt { color: #66d9ef } /* Keyword.Type */ .highlight .ld { color: #e6db74 } /* Literal.Date */ .highlight .m { color: #ae81ff } /* Literal.Number */ .highlight .s { color: #e6db74 } /* Literal.String */ .highlight .na { color: #a6e22e } /* Name.Attribute */ .highlight .nb { color: #f8f8f2 } /* Name.Builtin */ .highlight .nc { color: #a6e22e } /* Name.Class */ .highlight .no { color: #66d9ef } /* Name.Constant */ .highlight .nd { color: #a6e22e } /* Name.Decorator */ .highlight .ni { color: #f8f8f2 } /* Name.Entity */ .highlight .ne { color: #a6e22e } /* Name.Exception */ .highlight .nf { color: #a6e22e } /* Name.Function */ .highlight .nl { color: #f8f8f2 } /* Name.Label */ .highlight .nn { color: #f8f8f2 } /* Name.Namespace */ .highlight .nx { color: #a6e22e } /* Name.Other */ .highlight .py { color: #f8f8f2 } /* Name.Property */ .highlight .nt { color: #f92672 } /* Name.Tag */ .highlight .nv { color: #f8f8f2 } /* Name.Variable */ .highlight .ow { color: #f92672 } /* Operator.Word */ .highlight .w { color: #f8f8f2 } /* Text.Whitespace */ .highlight .mb { color: #ae81ff } /* Literal.Number.Bin */ .highlight .mf { color: #ae81ff } /* Literal.Number.Float */ .highlight .mh { color: #ae81ff } /* Literal.Number.Hex */ .highlight .mi { color: #ae81ff } /* Literal.Number.Integer */ .highlight .mo { color: #ae81ff } /* Literal.Number.Oct */ .highlight .sa { color: #e6db74 } /* Literal.String.Affix */ .highlight .sb { color: #e6db74 } /* Literal.String.Backtick */ .highlight .sc { color: #e6db74 } /* Literal.String.Char */ .highlight .dl { color: #e6db74 } /* Literal.String.Delimiter */ .highlight .sd { color: #e6db74 } /* Literal.String.Doc */ .highlight .s2 { color: #e6db74 } /* Literal.String.Double */ .highlight .se { color: #ae81ff } /* Literal.String.Escape */ .highlight .sh { color: #e6db74 } /* Literal.String.Heredoc */ .highlight .si { color: #e6db74 } /* Literal.String.Interpol */ .highlight .sx { color: #e6db74 } /* Literal.String.Other */ .highlight .sr { color: #e6db74 } /* Literal.String.Regex */ .highlight .s1 { color: #e6db74 } /* Literal.String.Single */ .highlight .ss { color: #e6db74 } /* Literal.String.Symbol */ .highlight .bp { color: #f8f8f2 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #a6e22e } /* Name.Function.Magic */ .highlight .vc { color: #f8f8f2 } /* Name.Variable.Class */ .highlight .vg { color: #f8f8f2 } /* Name.Variable.Global */ .highlight .vi { color: #f8f8f2 } /* Name.Variable.Instance */ .highlight .vm { color: #f8f8f2 } /* Name.Variable.Magic */ .highlight .il { color: #ae81ff } /* Literal.Number.Integer.Long */ } @media (prefers-color-scheme: light) { .highlight .hll { background-color: #ffffcc } .highlight .c { color: #888888 } /* Comment */ .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ .highlight .k { color: #008800; font-weight: bold } /* Keyword */ .highlight .ch { color: #888888 } /* Comment.Hashbang */ .highlight .cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
#!/usr/bin/env python

"""\
Sanitize a bitbake file following the OpenEmbedded style guidelines,
see http://openembedded.org/wiki/StyleGuide 

(C) 2006 Cyril Romain <cyril.romain@gmail.com>
MIT license

TODO: 
 - add the others OpenEmbedded variables commonly used:
 - parse command arguments and print usage on misuse
    . prevent giving more than one .bb file in arguments
 - write result to a file
 - backup the original .bb file
 - make a diff and ask confirmation for patching ?
 - do not use startswith only:
    /!\ startswith('SOMETHING') is not taken into account due to the previous startswith('S').
 - count rule breaks and displays them in the order frequence
"""

import fileinput
import string
import re

__author__ = "Cyril Romain <cyril.romain@gmail.com>"
__version__ = "$Revision: 0.5 $"

# The standard set of variables often found in .bb files in the preferred order
OE_vars = [
    'SUMMARY',
    'DESCRIPTION',
    'AUTHOR',
    'HOMEPAGE',
    'SECTION',
    'LICENSE',
    'LIC_FILES_CHKSUM',
    'DEPENDS',
    'PROVIDES',
    'SRCREV',
    'SRCDATE',
    'PE',
    'PV',
    'PR',
    'INC_PR',
    'SRC_URI',
    'S',
    'GPE_TARBALL_SUFFIX',
    'inherit',
    'EXTRA_',
    'export',
    'do_fetch',
    'do_unpack',
    'do_patch',
    'WORKDIR',
    'acpaths',
    'do_configure',
    'do_compile',
    'do_install',
    'PACKAGES',
    'PACKAGE_ARCH',
    'RDEPENDS',
    'RRECOMMENDS',
    'RSUGGESTS',
    'RPROVIDES',
    'RCONFLICTS',
    'FILES',    
    'do_package',
    'do_stage',
    'addhandler',
    'addtask',
    'bindir',
    'headers',
    'include',
    'includedir',
    'python',
    'qtopiadir',
    'pkg_preins',
    'pkg_prerm',
    'pkg_postins',
    'pkg_postrm',
    'require',
    'sbindir',
    'basesysconfdir',
    'sysconfdir',
    'ALLOW_EMPTY',
    'ALTERNATIVE_NAME',
    'ALTERNATIVE_PATH',
    'ALTERNATIVE_LINK',
    'ALTERNATIVE_PRIORITY',
    'ALTNAME',
    'AMD_DRIVER_LABEL',
    'AMD_DRIVER_VERSION',
    'ANGSTROM_EXTRA_INSTALL',
    'APPDESKTOP',
    'APPIMAGE',
    'APPNAME',
    'APPTYPE',
    'APPWEB_BUILD',
    'APPWEB_HOST',
    'AR',
    'ARCH',
    'ARM_INSTRUCTION_SET',
    'ARM_MUTEX',
    'ART_CONFIG',
    'B',
    'BJAM_OPTS',
    'BJAM_TOOLS',
    'BONOBO_HEADERS',
    'BOOTSCRIPTS',
    'BROKEN',
    'BUILD_CPPFLAGS',
    'CFLAGS',
    'CCFLAGS',
    'CMDLINE',
    'COLLIE_MEMORY_SIZE',
    'COMPATIBLE_HOST',
    'COMPATIBLE_MACHINE',
    'COMPILE_HERMES',
    'CONFFILES',
    'CONFLICTS',
    'CORE_EXTRA_D',
    'CORE_PACKAGES_D',
    'CORE_PACKAGES_RD',
    'CPPFLAGS',
    'CVSDATE',
    'CXXFLAGS',
    'DEBIAN_NOAUTONAME',
    'DEBUG_APPS',
    'DEFAULT_PREFERENCE',
    'DB4_CONFIG',
    'EXCLUDE_FROM_SHLIBS',
    'EXCLUDE_FROM_WORLD',
    'FIXEDSRCDATE',
    'GLIBC_ADDONS',
    'GLIBC_EXTRA_OECONF',
    'GNOME_VFS_HEADERS',
    'HEADERS',
    'INHIBIT_DEFAULT_DEPS',
    'INITSCRIPT_PACKAGES',
    'INITSCRIPT_NAME',
    'INITSCRIPT_PARAMS',
    'PACKAGE_INSTALL',
    'KERNEL_IMAGETYPE',
    'KERNEL_IMAGEDEST',
    'KERNEL_OUTPUT',
    'KERNEL_RELEASE',
    'KERNEL_PRIORITY',
    'KERNEL_SOURCE',
    'KERNEL_SUFFIX',
    'KERNEL_VERSION',
    'K_MAJOR',
    'K_MICRO',
    'K_MINOR',
    'HHV',
    'KV',
    'LDFLAGS',
    'LD',
    'LD_SO',
    'LDLIBS',
    'LEAD_SONAME',
    'LIBTOOL',
    'LIBBDB_EXTRA',
    'LIBV',
    'MACHINE_ESSENTIAL_EXTRA_RDEPENDS',
    'MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS',
    'MACHINE_EXTRA_RDEPENDS',
    'MACHINE_EXTRA_RRECOMMENDS',
    'MACHINE_FEATURES',
    'MACHINE_TASKS',
    'MACHINE',
    'MACHTYPE',
    'MAKE_TARGETS',
    'MESSAGEUSER',
    'MESSAGEHOME',
    'MIRRORS',
    'MUTEX',
    'OE_QMAKE_INCDIR_QT',
    'OE_QMAKE_CXXFLAGS',
    'ORBIT_IDL_SRC',
    'PARALLEL_MAKE',
    'PAKCAGE_ARCH',
    'PCMCIA_MANAGER',
    'PKG_BASENAME',
    'PKG',
    'QEMU',
    'QMAKE_PROFILES',
    'QPEDIR',
    'QPF_DESCRIPTION',
    'QPF_PKGPATTERN',
    'QT_CONFIG_FLAGS',
    'QT_LIBRARY',
    'ROOTFS_POSTPROCESS_COMMAND',
    'RREPLACES',
    'TARGET_CFLAGS',
    'TARGET_CPPFLAGS',
    'TARGET_LDFLAGS',
    'UBOOT_MACHINE',
    'UCLIBC_BASE',
    'UCLIBC_PATCHES',
    'VIRTUAL_NAME',
    'XORG_PN',
    'XSERVER',
    'others'
]

varRegexp = r'^([a-zA-Z_0-9${}-]*)([ \t]*)([+.:]?=[+.]?)([ \t]*)([^\t]+)'
routineRegexp = r'^([a-zA-Z0-9_ ${}-]+?)\('

# Variables seen in the processed .bb
seen_vars = {}
for v in OE_vars: 
    seen_vars[v] = []

# _Format guideline #0_: 
#   No spaces are allowed at the beginning of lines that define a variable or 
#   a do_ routine
def respect_rule0(line): 
    return line.lstrip()==line
def conformTo_rule0(line): 
    return line.lstrip()

# _Format guideline #1_: 
#   No spaces are allowed behind the line continuation symbol '\'
def respect_rule1(line):
    if line.rstrip().endswith('\\'):
        return line.endswith('\\')
    else: 
        return True
def conformTo_rule1(line):
    return line.rstrip()

# _Format guideline #2_: 
#   Tabs should not be used (use spaces instead).
def respect_rule2(line):
    return line.count('\t')==0
def conformTo_rule2(line):
    return line.expandtabs()

# _Format guideline #3_:
#   Comments inside bb files are allowed using the '#' character at the 
#   beginning of a line.
def respect_rule3(line):
    if line.lstrip().startswith('#'):
        return line.startswith('#')
    else: 
        return True
def conformTo_rule3(line):
    return line.lstrip()

# _Format guideline #4_:
#   Use quotes on the right hand side of assignments FOO = "BAR"
def respect_rule4(line):
    r = re.search(varRegexp, line)
    if r is not None:
        r2 = re.search(r'("?)([^"\\]*)(["\\]?)', r.group(5))
        # do not test for None it because always match
        return r2.group(1)=='"' and r2.group(3)!=''
    return False
def conformTo_rule4(line):
    r = re.search(varRegexp, line)
    return ''.join([r.group(1), ' ', r.group(3), ' "', r.group(5), r.group(5).endswith('"') and '' or '"'])

# _Format guideline #5_:
#   The correct spacing for a variable is FOO = "BAR".
def respect_rule5(line):
    r = re.search(varRegexp, line)
    return r is not None and r.group(2)==" " and r.group(4)==" "
def conformTo_rule5(line):
    r = re.search(varRegexp, line)
    return ''.join([r.group(1), ' ', r.group(3), ' ', r.group(5)])

# _Format guideline #6_:
#   Don't use spaces or tabs on empty lines
def respect_rule6(line):
    return not line.isspace() or line=="\n"
def conformTo_rule6(line):
    return ""

# _Format guideline #7_:
#   Indentation of multiline variables such as SRC_URI is desireable.
def respect_rule7(line):
    return True
def conformTo_rule7(line):
    return line

rules = (
    (respect_rule0, conformTo_rule0, "No spaces are allowed at the beginning of lines that define a variable or a do_ routine"),
    (respect_rule1, conformTo_rule1, "No spaces are allowed behind the line continuation symbol '\\'"),
    (respect_rule2, conformTo_rule2, "Tabs should not be used (use spaces instead)"),
    (respect_rule3, conformTo_rule3, "Comments inside bb files are allowed using the '#' character at the beginning of a line"),
    (respect_rule4, conformTo_rule4, "Use quotes on the right hand side of assignments FOO = \"BAR\""),
    (respect_rule5, conformTo_rule5, "The correct spacing for a variable is FOO = \"BAR\""),
    (respect_rule6, conformTo_rule6, "Don't use spaces or tabs on empty lines"),
    (respect_rule7, conformTo_rule7, "Indentation of multiline variables such as SRC_URI is desireable"),
)

# Function to check that a line respects a rule. If not, it tries to conform
# the line to the rule. Reminder or Disgression message are dump accordingly.
def follow_rule(i, line):
    oldline = line
    # if the line does not respect the rule
    if not rules[i][0](line):
        # try to conform it to the rule
        line = rules[i][1](line)
        # if the line still does not respect the rule
        if not rules[i][0](line):
            # this is a rule disgression
            print ("## Disgression: ", rules[i][2], " in:", oldline)
        else:
            # just remind user about his/her errors
            print ("## Reminder: ", rules[i][2], " in :", oldline)
    return line


if __name__ == "__main__":

    # -- retrieves the lines of the .bb file --
    lines = []
    for line in fileinput.input():
        # use 'if True' to warn user about all the rule he/she breaks
        # use 'if False' to conform to rules{2,1,6} without warnings
        if True:
            lines.append(line)
        else:
            # expandtabs on each line so that rule2 is always respected 
            # rstrip each line so that rule1 is always respected 
            line = line.expandtabs().rstrip()
            # ignore empty lines (or line filled with spaces or tabs only)
            # so that rule6 is always respected
            if line is not '':
                lines.append(line)

    # -- parse the file --
    var = ""
    in_routine = False
    commentBloc = []
    olines = []
    for line in lines: 
        originalLine = line
        # rstrip line to remove line breaks characters
        line = line.rstrip()
        line = follow_rule(2, line)
        line = follow_rule(1, line)
        line = follow_rule(6, line)

        # ignore empty lines
        if line.isspace() or line is '':
            # flush comments into the olines
            for c in commentBloc: olines.append(c)
            commentBloc = []
            continue

        if line.startswith('}'): 
            in_routine=False
        keep = line.endswith('\\') or in_routine

        # handles commented lines
        if line.lstrip().startswith('#'):
            # check and follow rule3 if not in a variables or routines
            if not in_routine:
                line = follow_rule(3, line)
            commentBloc.append(line)
            continue

        if var in seen_vars:
            for c in commentBloc: seen_vars[var].append(c)
            commentBloc = []
            seen_vars[var].append(line)
        else:
            for k in OE_vars:
                if line.startswith(k):
                    var = k
                    break
            if re.match(routineRegexp, line) is not None: 
                in_routine=True
                line = follow_rule(0, line)
            elif re.match(varRegexp, line) is not None:
                line = follow_rule(0, line)
                line = follow_rule(4, line)
                line = follow_rule(5, line)
            if var == "":
                if not in_routine:
                    print ("## Warning: unknown variable/routine \"%s\"" % originalLine.rstrip('\n'))
                var = 'others'
            for c in commentBloc: seen_vars[var].append(c)
            commentBloc = []
            seen_vars[var].append(line)
        if not keep and not in_routine: var = ""

    # -- dump the sanitized .bb file --
    addEmptyLine = False
    # write comments that are not related to variables nor routines
    for l in commentBloc: olines.append(l)
    # write variables and routines
    previourVarPrefix = "unknown"
    for k in OE_vars:
        if k=='SRC_URI': addEmptyLine = True
        if seen_vars[k] != []: 
            if addEmptyLine and not k.startswith(previourVarPrefix):
                olines.append("")
            for l in seen_vars[k]: 
                olines.append(l)
            previourVarPrefix = k.split('_')[0]=='' and "unknown" or k.split('_')[0]
    for line in olines: print(line)