text stringlengths 0 828 |
|---|
return cfg, cfg_files" |
1488,"def _dict_from_dotted(key, val): |
""""""takes a key value pair like: |
key: ""this.is.a.key"" |
val: ""the value"" |
and returns a dictionary like: |
{""this"": |
{""is"": |
{""a"": |
{""key"": |
""the value"" |
} |
} |
} |
} |
"""""" |
split_key = key.split(""."") |
split_key.reverse() |
for key_part in split_key: |
new_dict = DotDict() |
new_dict[key_part] = val |
val = new_dict |
return val" |
1489,"def get_logger(name, CFG=None): |
""""""set up logging for a service using the py 2.7 dictConfig |
"""""" |
logger = logging.getLogger(name) |
if CFG: |
# Make log directory if it doesn't exist |
for handler in CFG.get('handlers', {}).itervalues(): |
if 'filename' in handler: |
log_dir = os.path.dirname(handler['filename']) |
if not os.path.exists(log_dir): |
os.makedirs(log_dir) |
try: |
#TODO: This requires python 2.7 |
logging.config.dictConfig(CFG) |
except AttributeError: |
print >> sys.stderr, '""logging.config.dictConfig"" doesn\'t seem to be supported in your python' |
raise |
return logger" |
1490,"def t_TITLE(self, token): |
ur'\#\s+<wca-title>(?P<title>.+)\n' |
token.value = token.lexer.lexmatch.group(""title"").decode(""utf8"") |
token.lexer.lineno += 1 |
return token" |
1491,"def t_LABELDECL(self, token): |
ur'-\s<label>\s*\[(?P<label>.+?)\]\s*(?P<text>.+?)\n' |
label = token.lexer.lexmatch.group(""label"").decode(""utf8"") |
text = token.lexer.lexmatch.group(""text"").decode(""utf8"") |
token.value = (label, text) |
token.lexer.lineno += 1 |
return token" |
1492,"def t_ARTICLEHEADER(self, token): |
# \xef\xbc\x9a is the ""fullwidth colon"" used in Japanese for instance |
ur'\#\#\s+<article-(?P<number>[A-Z0-9]+)><(?P<newtag>[a-zA-Z0-9-]+)><(?P<oldtag>[a-zA-Z0-9-]+)>[ ]*(?P<name>[^\<]+?)(?P<sep>:\s|\xef\xbc\x9a)(?P<title>[^<\n]+)\n' |
number = token.lexer.lexmatch.group(""number"").decode(""utf8"") |
newtag = token.lexer.lexmatch.group(""newtag"").decode(""utf8"") |
oldtag = token.lexer.lexmatch.group(""oldtag"").decode(""utf8"") |
name = token.lexer.lexmatch.group(""name"").decode(""utf8"") |
sep = token.lexer.lexmatch.group(""sep"").decode(""utf8"") |
title = token.lexer.lexmatch.group(""title"").decode(""utf8"") |
token.value = (number, newtag, oldtag, name, title, sep) |
token.lexer.lineno += 1 |
return token" |
1493,"def t_STATESHEADER(self, token): |
ur'\#\#\s+<states-list>(?P<title>[^<\n]*)\n' |
title = token.lexer.lexmatch.group(""title"").decode(""utf8"") |
token.value = title |
token.lexer.lineno += 1 |
return token" |
1494,"def t_REGULATION(self, token): |
ur'(?P<indents>\s{4,})*-\s(?P<reg>[a-zA-Z0-9]+)\)\s*(?P<text>.+?[^ ])\n' |
indents = token.lexer.lexmatch.group(""indents"") |
indents = len(indents)/4 if indents else 0 |
reg = token.lexer.lexmatch.group(""reg"").decode(""utf8"") |
text = token.lexer.lexmatch.group(""text"").decode(""utf8"") |
token.value = (indents, reg, text) |
token.lexer.lineno += 1 |
return token" |
1495,"def t_GUIDELINE(self, token): |
ur'-\s(?P<reg>[a-zA-Z0-9]+[+]+)\)\s\[(?P<label>.+?)\]\s*(?P<text>.+?[^ ])\n' |
reg = token.lexer.lexmatch.group(""reg"").decode(""utf8"") |
text = token.lexer.lexmatch.group(""text"").decode(""utf8"") |
label = token.lexer.lexmatch.group(""label"").decode(""utf8"") |
token.value = (0, reg, text, label) |
token.lexer.lineno += 1 |
return token" |
1496,"def t_STATE(self, token): |
ur'-\s\((?P<state>[A-Z]{2}):(?P<continent>[_A-Za-z ]+)(:(?P<friendly_id>[A-Za-z_]+))?\)\s(?P<name>[A-Z].+?[^ ])\n' |
state = token.lexer.lexmatch.group(""state"").decode(""utf8"") |
continent = token.lexer.lexmatch.group(""continent"").decode(""utf8"") |
name = token.lexer.lexmatch.group(""name"").decode(""utf8"") |
friendly_id = token.lexer.lexmatch.group(""friendly_id"") |
if friendly_id: |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.