Traceback (most recent call last):
File "lib/sdk/FileType.py", line 28, in <module>
makefile.get("")
File "lib/sdk/FileType.py", line 15, in get
print(list(tuple([ key.strip(), value.strip() ]) for key, value in re.split( r"[\?:]?=|##", line ) if len(line) > 0))
File "lib/sdk/FileType.py", line 15, in <genexpr>
print(list(tuple([ key.strip(), value.strip() ]) for key, value in re.split( r"[\?:]?=|##", line ) if len(line) > 0))
ValueError: too many values to unpack (expected 2)
Created
February 7, 2020 20:47
-
-
Save lighth7015/f35bae8720854eee0b4b7ec42aeef5d0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re, os.path as path | |
class Makefile(object): | |
def __init__(self, filename): | |
if path.exists(filename): | |
self.handle = open(filename) | |
def get(self, name, default = None): | |
value = default | |
for it in self.handle.readlines(): | |
if len(line := it.strip()) > 0: | |
if line[0] != '#': | |
print(list(tuple(it) for it in re.split( r".?=|##", line ) if len(line) > 0)) | |
#result = [tuple(key.strip(), value.strip()) for key, value in list( it for it in re.split( r"[\?:]=|##", line ))] | |
#print(result) | |
return value | |
makefile = Makefile("global.cfg") | |
makefile.get("") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# generated file, do not edit! | |
BUILDCFG ?= release | |
DEFAULT_CFLAGS := -std=c99 | |
DEFAULT_CC=clang |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment