def makeJar(self, infile, jardir): '''makeJar is the main entry point to JarMaker. It takes the input file, the output directory, the source dirs and the top source dir as argument, and optionally the l10n dirs. ''' # making paths absolute, guess srcdir if file and add to sourcedirs _normpath = lambda p: os.path.normpath(os.path.abspath(p)) self.topsourcedir = _normpath(self.topsourcedir) self.sourcedirs = [_normpath(p) for p in self.sourcedirs] if self.localedirs: self.localedirs = [_normpath(p) for p in self.localedirs] elif self.relativesrcdir: self.localedirs = self.generateLocaleDirs(self.relativesrcdir) if isinstance(infile, str): logging.info("processing " + infile) self.sourcedirs.append(_normpath(os.path.dirname(infile))) pp = self.pp.clone() pp.out = StringIO() pp.do_include(infile) lines = pushback_iter(pp.out.getvalue().splitlines()) try: while True: l = next(lines) m = self.jarline.match(l) if not m: raise RuntimeError(l) if m.group('jarfile') is None: # comment continue self.processJarSection(m.group('jarfile'), lines, jardir) except StopIteration: # we read the file pass return
def staff_report_properties(doc): """Extract a dictionary of properties from the plaintext contents of a Planning Staff Report. """ sections = staff_report_sections( filter_lines(doc.line_iterator, STRIP_LINES)) props = {} props.update(somerville_properties(sections["header"])) for section in sections: if "staff report" in section: props.update(somerville_properties(sections[section])) # TODO: Consider using the legal notice as summary desc_section = sections.get("project description") if desc_section: subsections = make_sections( pushback_iter(filter_lines(desc_section, STRIP_ADDITIONAL)), [subsection_matcher]) for pname in [ "Proposal", "Subject Property", "Green Building Practices" ]: v = subsections.get(pname) if v: props[pname] = "\n".join(paragraphize(v)) return props
def makeJar(self, infile=None, jardir='', sourcedirs=[], topsourcedir='', localedirs=None): '''makeJar is the main entry point to JarMaker. It takes the input file, the output directory, the source dirs and the top source dir as argument, and optionally the l10n dirs. ''' if isinstance(infile, basestring): logging.info("processing " + infile) pp = self.pp.clone() pp.out = StringIO() pp.do_include(infile) lines = pushback_iter(pp.out.getvalue().splitlines()) try: while True: l = lines.next() m = self.jarline.match(l) if not m: raise RuntimeError(l) if m.group('jarfile') is None: # comment continue self.processJarSection(m.group('jarfile'), lines, jardir, sourcedirs, topsourcedir, localedirs) except StopIteration: # we read the file pass return
def makeJar(self, infile, jardir): '''makeJar is the main entry point to JarMaker. It takes the input file, the output directory, the source dirs and the top source dir as argument, and optionally the l10n dirs. ''' # making paths absolute, guess srcdir if file and add to sourcedirs _normpath = lambda p: os.path.normpath(os.path.abspath(p)) self.topsourcedir = _normpath(self.topsourcedir) self.sourcedirs = [_normpath(p) for p in self.sourcedirs] if self.localedirs: self.localedirs = [_normpath(p) for p in self.localedirs] elif self.relativesrcdir: self.localedirs = self.generateLocaleDirs(self.relativesrcdir) if isinstance(infile, basestring): logging.info("processing " + infile) self.sourcedirs.append(_normpath(os.path.dirname(infile))) pp = self.pp.clone() pp.out = StringIO() pp.do_include(infile) lines = pushback_iter(pp.out.getvalue().splitlines()) try: while True: l = lines.next() m = self.jarline.match(l) if not m: raise RuntimeError(l) if m.group('jarfile') is None: # comment continue self.processJarSection(m.group('jarfile'), lines, jardir) except StopIteration: # we read the file pass return
def makeJar(self, infile=None, jardir='', sourcedirs=[], topsourcedir='', localedirs=None): '''makeJar is the main entry point to JarMaker. It takes the input file, the output directory, the source dirs and the top source dir as argument, and optionally the l10n dirs. ''' if isinstance(infile, basestring): logging.info("processing " + infile) pp = self.pp.clone() pp.out = StringIO() pp.do_include(infile) lines = pushback_iter(pp.out.getvalue().splitlines()) try: while True: l = lines.next() m = self.jarline.match(l) if not m: raise RuntimeError(l) if m.group('jarfile') is None: # comment continue self.processJarSection( m.group('jarfile'), lines, jardir, sourcedirs, topsourcedir, localedirs) except StopIteration: # we read the file pass return
def staff_report_properties(doc): """Extract a dictionary of properties from the plaintext contents of a Planning Staff Report. """ sections = staff_report_sections(filter_lines(doc.line_iterator, STRIP_LINES)) attrs = {} props = {} attrs.update(somerville_properties(sections["header"])) for section in sections: if "staff report" in section: attrs.update(somerville_properties(sections[section])) try: if not doc.proposal.summary and "Legal Notice" in attrs: props["summary"] = attrs["Legal Notice"] except AttributeError: pass if "Recommendation" in attrs and not doc.proposal.status: if re.match(r"^(?i)(conditional )?approval", attrs["Recommendation"]): props["status"] = "Recommend Approval" elif re.match(r"^(?i)denial", attrs["Recommendation"]): props["status"] = "Recommend Denial" desc_section = sections.get("project description") if desc_section: subsections = make_sections( pushback_iter(filter_lines(desc_section, STRIP_ADDITIONAL)), [subsection_matcher]) for pname in [ "Proposal", "Subject Property", "Green Building Practices" ]: v = subsections.get(pname) if v: attrs[pname] = "\n".join(paragraphize(v)) return props, attrs
def staff_report_properties(doc_json): """Extract a dictionary of properties from the plaintext contents of a Planning Staff Report. """ sections = staff_report_sections(doc_json) props = {} props.update(properties(sections["header"])) props.update(properties(sections["planning staff report"])) pd = sections.get("project description") if pd: subsections = make_sections(pushback_iter(pd), [subsection_matcher]) for pname in [ "Proposal", "Subject Property", "Green Building Practices" ]: v = subsections.get(pname) if v: props[pname] = "\n".join(paragraphize(v)) return props