self._pos = output.tell() be32(output, 0xFFFFFFFF) def set(self, val=None): if val is None: val = self._output.tell() self._offset = val pos = self._output.tell() self._output.seek(self._pos) be32(self._output, val) self._output.seek(pos) def get(self): return self._offset p = DBParser() countries = p.parse(open(sys.argv[2], 'r', encoding='utf-8')) countrynames = list(countries) countrynames.sort() power = [] bands = [] for alpha2 in countrynames: for perm in countries[alpha2].permissions: if not perm.freqband in bands: bands.append(perm.freqband) if not perm.power in power: power.append(perm.power) rules = create_rules(countries) rules.sort()
self._pos = output.tell() be32(output, 0xFFFFFFFF) def set(self, val=None): if val is None: val = self._output.tell() self._offset = val pos = self._output.tell() self._output.seek(self._pos) be32(self._output, val) self._output.seek(pos) def get(self): return self._offset p = DBParser() countries = p.parse(file(sys.argv[2])) power = [] bands = [] for c in countries.itervalues(): for perm in c.permissions: if not perm.freqband in bands: bands.append(perm.freqband) if not perm.power in power: power.append(perm.power) rules = create_rules(countries) rules.sort(cmp=lambda x, y: cmp(x.freqband, y.freqband)) collections = create_collections(countries) collections.sort(cmp=lambda x, y: cmp(x[0].freqband, y[0].freqband)) output = StringIO()
be32(output, 0xFFFFFFFF) def set(self, val=None): if val is None: val = self._output.tell() self._offset = val pos = self._output.tell() self._output.seek(self._pos) be32(self._output, val) self._output.seek(pos) def get(self): return self._offset p = DBParser() countries = p.parse(file(sys.argv[2])) power = [] bands = [] for c in countries.itervalues(): for perm in c.permissions: if not perm.freqband in bands: bands.append(perm.freqband) if not perm.power in power: power.append(perm.power) rules = create_rules(countries) rules.sort(cmp=lambda x, y: cmp(x.freqband, y.freqband)) collections = create_collections(countries) collections.sort(cmp=lambda x, y: cmp(x[0].freqband, y[0].freqband)) output = StringIO()
def macro_Regulatory(macro): _ = macro.request.getText request = macro.request f = macro.formatter country = request.form.get('alpha2', [None])[0] dbpath = '/tmp/db.txt' if hasattr(request.cfg, 'regdb_path'): dbpath = request.cfg.regdb_path result = [] if request.form.get('raw', [None])[0]: result.append(f.code_area(1, 'db-raw', show=1, start=1, step=1)) for line in open(dbpath): result.extend([ f.code_line(1), f.text(line.rstrip()), f.code_line(0), ]) result.append(f.code_area(0, 'db-raw')) result.append(macro.request.page.link_to(macro.request, 'return to country list')) return ''.join(result) warnings = [] countries = DBParser(warn=lambda x: warnings.append(x)).parse(open(dbpath)) if country: return _country(macro, countries, country) countries = countries.keys() countries = [(_get_iso_code(code), code) for code in countries] countries.sort() result.extend([ f.heading(1, 1), f.text('Countries'), f.heading(0, 1), ]) result.append(f.bullet_list(1)) for name, code in countries: result.extend([ f.listitem(1), request.page.link_to(request, name, querystr={'alpha2': code}), f.listitem(0), ]) result.append(f.bullet_list(0)) if warnings: result.append(f.heading(1, 2)) result.append(f.text("Warnings")) result.append(f.heading(0, 2)) result.append(f.preformatted(1)) result.extend(warnings) result.append(f.preformatted(0)) result.append(request.page.link_to(request, 'view raw database', querystr={'raw': 1})) return ''.join(result)