Beispiel #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 ""
Beispiel #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 ""
Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #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, ""]
Beispiel #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, ""]
Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #21
0
def checkMatched(m):
    return utilities.checkMatched(m)
Beispiel #22
0
def checkMatched(m):
    return utilities.checkMatched(m)