def handle_main_housenr_additional_count( ctx: context.Context, relation: areas.Relation) -> yattag.doc.Doc: """Handles the housenumber additional count part of the main page.""" if not relation.get_config().should_check_additional_housenumbers(): return yattag.doc.Doc() prefix = ctx.get_ini().get_uri_prefix() url = prefix + "/additional-housenumbers/" + relation.get_name( ) + "/view-result" additional_count = "" if ctx.get_file_system().path_exists( relation.get_files().get_housenumbers_additional_count_path()): path = relation.get_files().get_housenumbers_additional_count_path() additional_count = util.get_content(path).decode("utf-8").strip() doc = yattag.doc.Doc() if additional_count: date = get_last_modified( relation.get_files().get_housenumbers_additional_count_path()) with doc.tag("strong"): with doc.tag("a", href=url, title=tr("updated") + " " + date): doc.text(tr("{} house numbers").format(additional_count)) return doc with doc.tag("strong"): with doc.tag("a", href=url): doc.text(tr("additional house numbers")) return doc
def get_missing_housenumbers_txt(ctx: context.Context, relation: areas.Relation) -> str: """Gets the cached plain text of the missing housenumbers for a relation.""" output = "" if is_missing_housenumbers_txt_cached(ctx, relation): with relation.get_files().get_housenumbers_txtcache_stream( "rb") as stream: output = util.from_bytes(stream.read()) return output ongoing_streets, _ignore = relation.get_missing_housenumbers() table = [] for result in ongoing_streets: range_list = util.get_housenumber_ranges(result[1]) range_strings = [i.get_number() for i in range_list] # Street name, only_in_reference items. if not relation.get_config().get_street_is_even_odd( result[0].get_osm_name()): result_sorted = sorted(range_strings, key=util.split_house_number) row = result[0].get_osm_name() + "\t[" + ", ".join( result_sorted) + "]" else: elements = util.format_even_odd(range_list, doc=None) row = result[0].get_osm_name() + "\t[" + "], [".join( elements) + "]" table.append(row) table.sort(key=util.get_lexical_sort_key()) output += "\n".join(table) with relation.get_files().get_housenumbers_txtcache_stream("wb") as stream: stream.write(util.to_bytes(output)) return output
def filter_for(_complete: bool, relation: areas.Relation) -> bool: r_config = relation.get_config() return r_config.get_refcounty( ) == refcounty_filter and r_config.get_refsettlement( ) == refsettlement_filter
def filter_for(_complete: bool, relation: areas.Relation) -> bool: config = relation.get_config() return config.get_refmegye() == refmegye_filter and config.get_reftelepules() == reftelepules_filter