Exemplo n.º 1
0
def getProperty(buffers, option):
    patt = re.compile("^ *" + option + " *:(.*)")
    for i in buffers:
        m = patt.match(i)
        if utilities.checkMatched(m):
            return m.group(1).strip()
    return ""
Exemplo n.º 2
0
def getProperty(buffers, option):
    patt = re.compile("^ *" + option + " *:(.*)")
    for i in buffers:
        m = patt.match(i)
        if utilities.checkMatched(m):
            return m.group(1).strip()
    return ""
Exemplo n.º 3
0
def getProperties(buffers):
    patt = re.compile(r"^ *(.*?):.*")
    returnme = {}
    for i in buffers:
        m = patt.match(i)
        if utilities.checkMatched(m):
            returnme[m.group(1)] = getProperty(buffers, m.group(1))
    return returnme
Exemplo n.º 4
0
def cleanComments(buffers):
    patt = re.compile("^ *#.*")
    returnme = []
    for i in buffers:
        m = patt.match(i)
        if not utilities.checkMatched(m):
            returnme.append(i)
    return returnme
Exemplo n.º 5
0
def cleanEmptyLines(buffers):
    patt = re.compile("^ *$")
    returnme = []
    for i in buffers:
        m = patt.match(i)
        if not utilities.checkMatched(m):
            returnme.append(i)
    return returnme
Exemplo n.º 6
0
def cleanEmptyLines(buffers):
    patt = re.compile("^ *$")
    returnme = []
    for i in buffers:
        m = patt.match(i)
        if not utilities.checkMatched(m):
            returnme.append(i)
    return returnme
Exemplo n.º 7
0
def cleanComments(buffers):
    patt = re.compile("^ *#.*")
    returnme = []
    for i in buffers:
        m = patt.match(i)
        if not utilities.checkMatched(m):
            returnme.append(i)
    return returnme
Exemplo n.º 8
0
def getProperties(buffers):
    patt = re.compile(r"^ *(.*?):.*")
    returnme = {}
    for i in buffers:
        m = patt.match(i)
        if utilities.checkMatched(m):
            returnme[m.group(1)] = getProperty(buffers, m.group(1))
    return returnme
Exemplo n.º 9
0
def getOptions(buffers):
    patt = re.compile("^ *Option *.*")
    returnme = []
    for i in buffers:
        m = patt.match(i)
        if utilities.checkMatched(m):
            returnme.append(i.split()[1].strip())
    return returnme
Exemplo n.º 10
0
def getOptions(buffers):
    patt = re.compile("^ *Option *.*")
    returnme = []
    for i in buffers:
        m = patt.match(i)
        if utilities.checkMatched(m):
            returnme.append(i.split()[1].strip())
    return returnme
Exemplo n.º 11
0
def getMultipleValues(buffers):
    returnme = []
    patt = re.compile("^ *(.*)")
    m = patt.match(buffers.strip())
    if utilities.checkMatched(m):
        for i in m.group(1).split():
            si = i.strip()
            returnme.append(si)
    return returnme
Exemplo n.º 12
0
 def _varEditor(self, line, lists):
     patt = re.compile("^.*? *([A-Za-z_-]*?)=.*$")
     m = patt.match(line)
     if utilities.checkMatched(m):
         for i in lists.keys():
             if m.group(1) == i:
                 bak = copy.copy(lists[i])
                 lists[i] = None
                 return [True, "export " + i + "=\"" + bak + "\"\n"]
     patt = re.compile("^ *#.*$")
     m = patt.match(line)
     if utilities.checkMatched(m):
         return [True, line]
     patt = re.compile("^ *$")
     m = patt.match(line)
     if utilities.checkMatched(m):
         return [True, line]
     return [False, ""]
Exemplo n.º 13
0
 def _varEditor(self, line, lists, export_str="export "):
     patt = re.compile("^.*? *([A-Za-z_-]*?)=.*$")
     m = patt.match(line)
     if utilities.checkMatched(m):
         for i in lists.keys():
             if m.group(1) == i:
                 bak = copy.copy(lists[i])
                 lists[i] = None
                 return [True, export_str + i + "=\"" + bak + "\"\n"]
     patt = re.compile("^ *#.*$")
     m = patt.match(line)
     if utilities.checkMatched(m):
         return [True, line]
     patt = re.compile("^ *$")
     m = patt.match(line)
     if utilities.checkMatched(m):
         return [True, line]
     return [False, ""]
Exemplo n.º 14
0
def getMultipleValues(buffers):
    returnme = []
    patt = re.compile("^ *(.*)")
    m = patt.match(buffers.strip())
    if utilities.checkMatched(m):
        for i in m.group(1).split():
            si = i.strip()
            returnme.append(si)
    return returnme
Exemplo n.º 15
0
def getChoices(buffers):
    returnme = []
    patt = re.compile("^ *" + choice + " *: *(.*)")
    m = patt.match(buffers.strip())
    if utilities.checkMatched(m):
        for i in m.group(1).split(","):
            si = i.strip()
            returnme.append(si)
    else:
        return None
    return returnme
Exemplo n.º 16
0
def getChoices(buffers):
    returnme = []
    patt = re.compile("^ *" + choice + " *: *(.*)")
    m = patt.match(buffers.strip())
    if utilities.checkMatched(m):
        for i in m.group(1).split(","):
            si = i.strip()
            returnme.append(si)
    else:
        return None
    return returnme
Exemplo n.º 17
0
def getSFSInstSize(files):
    # Not optimal, but it works
    # Sample line:
    #     drwxr-xr-x root/root               377 2012-04-25 10:04 squashfs-root
    #                                        ^^^
    #                                        Size in bytes
    patt = re.compile("^ *[dlspcb-][rwx-][rwx-][rwx-][rwx-][rwx-][rwx-][rwx-][rwx-][rwx-] *[A-Za-z0-9]*/[A-Za-z0-9]* *([0-9]*).*")
    output = os.popen("unsquashfs -lls " + files)
    totsize = 0
    for line in output:
        m = patt.match(line)
        if utilities.checkMatched(m):
            totsize = totsize + int(m.group(1))
    return totsize
Exemplo n.º 18
0
def getSFSInstSize(files):
    # Not optimal, but it works
    # Sample line:
    #     drwxr-xr-x root/root               377 2012-04-25 10:04 squashfs-root
    #                                        ^^^
    #                                        Size in bytes
    patt = re.compile(
        "^ *[dlspcb-][rwx-][rwx-][rwx-][rwx-][rwx-][rwx-][rwx-][rwx-][rwx-] *[A-Za-z0-9]*/[A-Za-z0-9]* *([0-9]*).*"
    )
    output = os.popen("unsquashfs -lls " + files)
    totsize = 0
    for line in output:
        m = patt.match(line)
        if utilities.checkMatched(m):
            totsize = totsize + int(m.group(1))
    return totsize
Exemplo n.º 19
0
def getLinesWithinOption(buffers, option):
    patt = re.compile("^ *Option *" + option + ".*")
    patte = re.compile("^ *EndOption *.*")
    returnme = []
    x = 0
    for i in buffers:
        m = patt.match(i)
        if utilities.checkMatched(m):
            if x == 1:
                break
            x = 1
            patt = patte
        else:
            if x == 1:
                returnme.append(i)
    return returnme
Exemplo n.º 20
0
def getLinesWithinOption(buffers, option):
    patt = re.compile("^ *Option *" + option + ".*")
    patte = re.compile("^ *EndOption *.*")
    returnme = []
    x = 0
    for i in buffers:
        m = patt.match(i)
        if utilities.checkMatched(m):
            if x == 1:
                break
            x = 1
            patt = patte
        else:
            if x == 1:
                returnme.append(i)
    return returnme
Exemplo n.º 21
0
def checkMatched(m):
    return utilities.checkMatched(m)
Exemplo n.º 22
0
def checkMatched(m):
    return utilities.checkMatched(m)