text stringlengths 0 828 |
|---|
'''content : TITLE opttexts VERSION opttexts sections |
| TITLE STATESTAG VERSION opttexts states_sections''' |
content[0] = self.doctype(content[1], content[3], content[4], content[5]) |
if self.toc: |
self.toc.set_articles([a for a in content[0].sections if isinstance(a, Article)])" |
410,"def p_text(self, text): |
'''text : TEXT PARBREAK |
| TEXT |
| PARBREAK''' |
item = text[1] |
text[0] = item if item[0] != ""\n"" else u"""" |
if len(text) > 2: |
text[0] += ""\n""" |
411,"def p_toc(self, toc): |
'''toc : HEADERSEC opttexts TOC opttexts''' |
toc[0] = TableOfContent(toc[1], toc[2], []) |
self.toc = toc[0]" |
412,"def p_article(self, article): |
'''article : ARTICLEHEADER opttexts rules opttexts''' |
article[0] = Article(article[1][4], article[2], article[3], article[1][0], |
article[1][1], article[1][2], article[1][3], article[1][5])" |
413,"def p_regularsec(self, regularsec): |
'''regularsec : HEADERSEC opttexts optsubsections''' |
texts = [] |
sections = regularsec[2] |
if len(regularsec) > 3: |
texts = regularsec[2] |
sections = regularsec[3] |
regularsec[0] = Section(regularsec[1], texts, sections)" |
414,"def p_subsection(self, subsection): |
'''subsection : HEADERSUBSEC texts |
| HEADERSUBSEC texts labeldecls opttexts''' |
content = subsection[3] if len(subsection) > 3 else [] |
subsection[0] = Subsection(subsection[1], subsection[2], content)" |
415,"def p_rule(self, rule): |
'''rule : GUIDELINE |
| REGULATION''' |
if len(rule[1]) == 4: |
# This is a guideline |
rule[0] = Guideline(rule[1][1], rule[1][2], rule[1][3]) |
else: |
# This is a regulation |
indentsize = rule[1][0] |
number = rule[1][1] |
text = rule[1][2] |
parent = None |
# If we just ""un""nested, shrink the current rule to our level |
if self.prev_indent > indentsize: |
self.current_rule = self.current_rule[0:indentsize+1] |
# We just added a nested level, the parent is the list's last elem |
if self.prev_indent < indentsize: |
parent = self.current_rule[-1] |
# Else, if we are nested the parent is the one before the last elem |
elif len(self.current_rule) > 1: |
parent = self.current_rule[-2] |
# Else if we are not nested, then we are a root rule and parent is none |
# (do nothing as parent is initialized to none) |
# Create the regulation node |
reg = Regulation(number, text, parent) |
# Let our parent knows he has a new child, if we don't have a parent |
# let's create an item in the article rules list |
if parent: |
parent.add_child(reg) |
else: |
rule[0] = reg |
# Unless we nested, pop and replace the last rule by ourself |
# If we added a nesting level, we just need to add ourself |
if self.prev_indent >= indentsize: |
self.current_rule.pop() |
self.current_rule.append(reg) |
self.prev_indent = indentsize" |
416,"def p_state(self, state): |
'''state : STATE opttexts''' |
state[0] = State(state[1][0], state[1][1], state[1][2], state[1][3], state[2])" |
417,"def p_error(self, elem): |
'''Handle syntax error''' |
self.errors.append(""Syntax error on line "" + str(self.lexer.lineno) |
+ "". Got unexpected token "" + elem.type)" |
418,"def set_progress_brackets(self, start, end): |
""""""Set brackets to set around a progress bar."""""" |
self.sep_start = start |
self.sep_end = end" |
419,"def add_progress(self, count, symbol='#', |
color=None, on_color=None, attrs=None): |
""""""Add a section of progress to the progressbar. |
The progress is captured by ""count"" and displayed as a fraction |
of the statusbar width proportional to this count over the total |
progress displayed. The progress will be displayed using the ""symbol"" |
character and the foreground and background colours and display style |
determined by the the ""color"", ""on_color"" and ""attrs"" parameters. |
These parameters work as the termcolor.colored function. |
"""""" |
chunk = _ProgressChunk(count, symbol, color, on_color, attrs) |
self._progress_chunks.append(chunk)" |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.