code
stringlengths
1
1.72M
language
stringclasses
1 value
#!/usr/binn/env/python from random import shuffle, choice, sample, random, randint from bisect import bisect from itertools import izip_longest from math import sqrt # helper stuff fst = lambda s: s[0] snd = lambda s: s[1] def grouper(n, iterable, fillvalue=None): "Collect data into fixed-length chunks or blocks...
Python
#!/usr/bin/env python from itertools import product class TSP: def __init__(self, graph): """graph = networkx undirected graph object. each edge has attribute "length".""" self.graph = graph.copy() def __len__(self): return len(self.graph) def tour_length(self, permutation...
Python
#!/usr/bin/env python class SAT: def __init__(self, clauses): """variable x_1 is denotet by '1', its negation by '-1'. clauses is a list of varible-lists: (x_1 or not x_2) and (x_2) == ((1, -2), (2,)).""" self.num_variables = len(set(abs(x) for xs in clauses for x in xs)) s...
Python
#!/usr/bin/env python from itertools import product import gurobipy as grb def parse_lines(iterator, rows, cols): """parse cols*rows lines from iterator. return list of lists where xs[row] = [ids of cols with value 1] ex.: input 0 0 1 1 parse_lines(_, 2, 2): xs = [[], [0, 1...
Python
#!/usr/binn/env/python from random import shuffle, choice, sample, random, randint from bisect import bisect from itertools import izip_longest from math import sqrt # helper stuff fst = lambda s: s[0] snd = lambda s: s[1] def grouper(n, iterable, fillvalue=None): "Collect data into fixed-length chunks or blocks...
Python
# Django settings for fereol project. import os DEBUG = True TEMPLATE_DEBUG = DEBUG # calculated paths for django and the site # used as starting points for various other paths SITE_ROOT = os.path.dirname(os.path.realpath(__file__)) ADMINS = ( # ('Your Name', 'your_email@domain.com'), ) MANAGERS = ADMINS DA...
Python
#!/usr/bin/env python from django.core.management import execute_manager try: import settings # Assumed to be in the same directory. except ImportError: import sys sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to ...
Python
from django.conf.urls.defaults import patterns from django.conf import settings # Uncomment the next two lines to enable the admin: # from django.contrib import admin # admin.autodiscover() urlpatterns = patterns('', (r'^$', 'fereol.views.index'), (r'^przedmiot/P(?P<id>\d+)$', 'fereol.views.przed...
Python
from django.shortcuts import render_to_response def index(request): return render_to_response("index.html", {}) def aktualnosci(request): return render_to_response("aktualnosci.html", {}) def pracownicy(request): return render_to_response("pracownicy.html", {}) def przedmioty(request): return render...
Python
#!/usr/bin/env python from django.core.management import execute_manager try: import settings # Assumed to be in the same directory. except ImportError: import sys sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to ...
Python
#==================================================================== # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you ...
Python
#!/usr/bin/env python # # Copyright 2007 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law o...
Python
#!/usr/bin/env python # # Copyright 2007 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law o...
Python
#!/usr/bin/env python # # Copyright 2007 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law o...
Python
#!/usr/bin/env python # # Copyright 2007 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law o...
Python
from google.appengine.ext import db class Greeting(db.Model): author = db.UserProperty() content = db.StringProperty(multiline=True) date = db.DateTimeProperty(auto_now_add=True) class Menu(db.Model): text = db.StringProperty(multiline=False) link = db.StringProperty(multiline=False)
Python
import os from google.appengine.ext.webapp import template import cgi from google.appengine.api import users from google.appengine.ext import webapp from google.appengine.ext.webapp.util import run_wsgi_app from model import * class MainPage(webapp.RequestHandler): def get(self): greetings_query = Greeting.all(...
Python
# -*- coding: utf-8 -*- # Django settings for the example project. import os DEBUG = True TEMPLATE_DEBUG = False ##LANGUAGE_CODE = 'zh-CN' ##LANGUAGE_CODE = 'fr' LOCALE_PATHS = 'locale' USE_I18N = True TEMPLATE_LOADERS=('django.template.loaders.filesystem.load_template_source', 'zipl...
Python
# -*- coding: utf-8 -*- import os,stat import sys import logging import wsgiref.handlers from mimetypes import types_map from datetime import datetime, timedelta from google.appengine.ext import webapp from google.appengine.ext.webapp import template from google.appengine.api import memcache from google.appen...
Python
#!/usr/bin/env python import optparse import os import sys def compile_messages(locale=None): basedir = None if os.path.isdir(os.path.join('conf', 'locale')): basedir = os.path.abspath(os.path.join('conf', 'locale')) elif os.path.isdir('locale'): basedir = os.path.abspath('locale') el...
Python
#!/usr/bin/env python import os import sys def unique_messages(): basedir = None if os.path.isdir(os.path.join('conf', 'locale')): basedir = os.path.abspath(os.path.join('conf', 'locale')) elif os.path.isdir('locale'): basedir = os.path.abspath('locale') else: print "this scri...
Python
#!/usr/bin/env python # Need to ensure that the i18n framework is enabled from django.conf import settings settings.configure(USE_I18N = True) from django.utils.translation import templatize import re import os import sys import getopt pythonize_re = re.compile(r'\n\s*//') def make_messages(): localedir = None ...
Python
#!/usr/bin/env python import optparse import os import sys def compile_messages(locale=None): basedir = None if os.path.isdir(os.path.join('conf', 'locale')): basedir = os.path.abspath(os.path.join('conf', 'locale')) elif os.path.isdir('locale'): basedir = os.path.abspath('locale') el...
Python
#!/usr/bin/env python # Need to ensure that the i18n framework is enabled from django.conf import settings settings.configure(USE_I18N = True) from django.utils.translation import templatize import re import os import sys import getopt pythonize_re = re.compile(r'\n\s*//') def make_messages(): localedir = None ...
Python
#!/usr/bin/env python import os import sys def unique_messages(): basedir = None if os.path.isdir(os.path.join('conf', 'locale')): basedir = os.path.abspath(os.path.join('conf', 'locale')) elif os.path.isdir('locale'): basedir = os.path.abspath('locale') else: print "this scri...
Python
from micolog_plugin import * import logging from model import * from google.appengine.api import users class highsyntax(Plugin): def __init__(self): Plugin.__init__(self,__file__) self.author="xuming" self.authoruri="http://xuming.net" self.uri="http://xuming.net" self.description="HighSyntax Plugi...
Python
from highsyntax import *
Python
from micolog_plugin import * from model import OptionSet class googleAnalytics(Plugin): def __init__(self): Plugin.__init__(self,__file__) self.author="xuming" self.authoruri="http://xuming.net" self.uri="http://xuming.net" self.description="Plugin for put google Analytics into micolog." self.name...
Python
from xheditor import *
Python
from micolog_plugin import * import logging,os from model import * from google.appengine.api import users class xheditor(Plugin): def __init__(self): Plugin.__init__(self,__file__) self.author="xuming" self.authoruri="http://xuming.net" self.uri="http://xuming.net" self.description="xheditor." s...
Python
from sys_plugin import *
Python
# -*- coding: utf-8 -*- from micolog_plugin import * import logging,re from google.appengine.api import mail from model import * from google.appengine.api import users from base import BaseRequestHandler,urldecode from google.appengine.ext.webapp import template SBODY='''New comment on your post "%(title)s" ...
Python
from micolog_plugin import * from google.appengine.api import memcache from google.appengine.api.labs import taskqueue from wp_import import * from model import * import logging,math from django.utils import simplejson from base import BaseRequestHandler,urldecode class waphandler(BaseRequestHandler): def...
Python
###Import post,page,category,tag from wordpress export file import xml.etree.ElementTree as et import logging ###import from wxr file class import_wordpress: def __init__(self,source): self.categories=[] self.tags=[] self.entries=[] self.source=source self.doc=et.fromstring(source) #use namesp...
Python
from wordpress import *
Python
# -*- coding: utf-8 -*- import os,logging import re from functools import wraps from google.appengine.api import users from google.appengine.ext import webapp from google.appengine.ext import db from google.appengine.ext.webapp import template from google.appengine.api import memcache from google.appengine.api...
Python
# -*- coding: utf-8 -*- import logging from django import template from model import * import django.template.defaultfilters as defaultfilters import urllib register = template.Library() from datetime import * @register.filter def datetz(date,format): #datetime with timedelta t=timedelta(seconds=3600*g_b...
Python
#!/usr/bin/env python # # Copyright 2007 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or a...
Python
# -*- coding: utf-8 -*- import wsgiref.handlers import xmlrpclib from xmlrpclib import Fault import sys import cgi import base64 #from datetime import datetime import app.mktimefix as datetime from SimpleXMLRPCServer import SimpleXMLRPCDispatcher from functools import wraps from django.utils.html import stri...
Python
# -*- coding: utf-8 -*- import cgi, os,sys,math import wsgiref.handlers import google.appengine.api # Google App Engine imports. from google.appengine.ext.webapp import util from google.appengine.ext.webapp import template, \ WSGIApplication from google.appengine.api import users ##import app.webapp as web...
Python
# Wrapper for loading templates from zipfile. import zipfile,logging,os from django.template import TemplateDoesNotExist from django.conf import settings logging.debug("zipload imported") zipfile_cache={} _TEMPLATES_='templates' def get_from_zipfile(zipfilename,name): logging.debug("get_from_zipfile(%s,%s)"%(zipfil...
Python
from django.template import Library from django.template import Node, NodeList, Template, Context from django.template import TemplateSyntaxError, VariableDoesNotExist, BLOCK_TAG_START, BLOCK_TAG_END, VARIABLE_TAG_START, VARIABLE_TAG_END, SINGLE_BRACE_START, SINGLE_BRACE_END, COMMENT_TAG_START, COMMENT_TAG_END registe...
Python
#!/usr/bin/env python """Simple PNG Canvas for Python""" __version__ = "0.8" __author__ = "Rui Carmo (http://the.taoofmac.com)" __copyright__ = "CC Attribution-NonCommercial-NoDerivs 2.0 Rui Carmo" __contributors__ = ["http://collaboa.weed.rbse.com/repository/file/branches/pgsql/lib/spark_pr.rb"], ["Eli Bendersky"] i...
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- # # Copyright(C) 2008 SupDo.com # Licensed under the GUN License, Version 3.0 (the "License"); # # File: safecode.py # Author: KuKei # Create Date: 2008-07-16 # Description: 负责验证码生成。 # Modify Date: 2008-08-06 import md5 import random from pngcanva...
Python
"""tblib.py: A Trackback (client) implementation in Python """ __author__ = "Matt Croydon <matt@ooiio.com>" __copyright__ = "Copyright 2003, Matt Croydon" __license__ = "GPL" __version__ = "0.1.0" __history__ = """ 0.1.0: 1/29/03 - Code cleanup, release. It can send pings, and autodiscover a URL to ping. 0.0.9...
Python
# -*- coding: utf-8 -*- """ A Python HTML filtering library - html_filter.py, v 1.15.4 Translated to Python by Samuel Adam <samuel.adam@gmail.com> http://amisphere.com/contrib/python-html-filter/ Original PHP code ( lib_filter.php, v 1.15 ) by Cal Henderson <cal@iamcal.com> http://i...
Python
from time import * from calendar import timegm # fix for mktime bug # https://garage.maemo.org/tracker/index.php?func=detail&aid=4453&group_id=854&atid=3201 mktime = lambda time_tuple: calendar.timegm(time_tuple) + timezone
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- # # Copyright(C) 2008 SupDo.com # Licensed under the GUN License, Version 3.0 (the "License"); # # File: safecode.py # Author: KuKei # Create Date: 2008-07-16 # Description: 负责验证码生成。 # Modify Date: 2008-08-06 import md5 import random from pngcanva...
Python
#!/usr/bin/env python # # Copyright 2007 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law o...
Python
#!/usr/bin/env python # # Copyright 2007 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law o...
Python
#!/usr/bin/env python """Simple PNG Canvas for Python""" __version__ = "0.8" __author__ = "Rui Carmo (http://the.taoofmac.com)" __copyright__ = "CC Attribution-NonCommercial-NoDerivs 2.0 Rui Carmo" __contributors__ = ["http://collaboa.weed.rbse.com/repository/file/branches/pgsql/lib/spark_pr.rb"], ["Eli Bendersky"] i...
Python
# gmemsess.py - memcache-backed session Class for Google Appengine # Version 1.4 # Copyright 2008 Greg Fawcett <greg@vig.co.nz> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3...
Python
import os,logging,re from model import OptionSet from google.appengine.ext.webapp import template from google.appengine.ext import zipserve RE_FIND_GROUPS = re.compile('\(.*?\)') class PluginIterator: def __init__(self, plugins_path='plugins'): self.iterating = False self.plugins_path = plugins_path sel...
Python
# -*- coding: utf-8 -*- import os,logging from google.appengine.api import users from google.appengine.ext import db from google.appengine.ext.db import Model as DBModel from google.appengine.api import memcache from google.appengine.api import mail from google.appengine.api import urlfetch from datetime import...
Python
# -*- coding: utf-8 -*- import cgi, os,sys,traceback import wsgiref.handlers ##os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' ##from django.conf import settings ##settings._target = None os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' from django.utils.translation import check_for_language, activate, to_loc...
Python
#!/usr/bin/env python # # Copyright 2007 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or a...
Python
import cgi from google.appengine.api import users from google.appengine.ext import webapp from google.appengine.ext.webapp.util import run_wsgi_app class MainPage(webapp.RequestHandler): def get(self): self.response.out.write(""" <html> <body> <form action="/sign" ...
Python
from . import CompoundElement import bs4 import six """The purpose of this module is to provide classes corresponding to most elements (except <style>, <script> and similar non-document content elements) and core attributes (except style and the %events attributes) of HTML4.01 and HTML5. It is not totally compliant wi...
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import unicode_literals """Several base datatypes that inherit from native types (unicode,list,dict, etc) or python defined types (datetime), but adds support for general attributes (properties). The attributes are set when instaniated (in the constructor ca...
Python
# -*- coding: utf-8 -*- from __future__ import unicode_literals import xml.etree.cElementTree as ET import os from io import BytesIO from rdflib import Literal, BNode, Namespace, URIRef from rdflib import Graph from rdflib.plugins.parsers.ntriples import NTriplesParser from rdflib import Namespace, URIRef, Literal, RDF...
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import unicode_literals import os import hashlib import json from datetime import datetime from ferenda import util class DocumentEntry(object): """This class has two primary uses -- it is used to represent and store aspects of the downloading of ...
Python
# -*- coding: utf-8 -*- from __future__ import unicode_literals, print_function """This module finds references to legal sources (including individual sections, eg 'Upphovsrättslag (1960:729) 49 a §') in plaintext""" import sys import os import re import codecs import traceback from io import StringIO from pprint impo...
Python
#!/usr/bin/env python import sys, os sys.path.append(os.path.normpath(os.getcwd()+os.sep+os.pardir)) from ferenda import manager manager.run(sys.argv[1:])
Python
#!/usr/bin/env python from __future__ import unicode_literals import os import sys sys.path.append("..") try: from ferenda.manager import make_wsgi_app # FIXME: should we chdir to os.path.dirname(__file__) instead? inifile = os.path.join(os.path.dirname(__file__), "ferenda.ini") applicatio...
Python
# -*- coding: utf-8 -*- from __future__ import unicode_literals """This module constructs URIs for a document based on the properties of that document. Alternatively, given a URI for a document, parse the different properties for the document""" # system libs import sys import re from pprint import pformat # 3rdparty...
Python
# -*- coding: utf-8 -*- from __future__ import unicode_literals """Fancy file-like-class for reading (not writing) text files by line, paragraph, page or any other user-defined unit of text, with support for peeking ahead and looking backwards. It can read files in different encodings, but converts/handles everything u...
Python
from operator import attrgetter class NewsCriteria(object): """Represents a particular subset of the documents in a repository, for the purpose of generating a news feed for that subset. :param basefile: A slug-like basic text label for this subset. :param feedtitle: ... :param selector: calla...
Python
# -*- coding: utf-8 -*- from __future__ import unicode_literals # ferenda.FSMParser - # # You don't have to. You may create ferenda.elements objects manually, or even create # your own lists-of-lists structure that render_xhtml can handle (or that you # transform into xhtml/rdfa yourself). import collections import...
Python
import six from six.moves import builtins _property = builtins.property _tuple = builtins.tuple from operator import itemgetter as _itemgetter class TocPage(tuple): 'TocPage(linktext, title, basefile)' __slots__ = () _fields = ('linktext', 'title', 'basefile') def __new__(_cls, linktext, title, basef...
Python
from . import DocumentRepository class PDFDocumentRepository(DocumentRepository): """Base class for handling repositories of PDF documents. Parsing of these documents are a bit more complicated than HTML or text documents, particularly with the handling of external resources such as CSS and image file...
Python
# -*- coding: utf-8 -*- from __future__ import unicode_literals class WordReader(object): """Reads .docx and .doc-files (the latter with support from antiword) and presents a slightly easier API for dealing with them.""" def read(self, wordfile, workdir=None): """Read the file""" pass def ...
Python
from . import DocumentRepository class CompositeRepository(DocumentRepository): instances = {} @classmethod def get_instance(cls, instanceclass, options={}): if not instanceclass in cls.instances: # print "Creating a %s class with options %r" % (instanceclass.__name__,options) ...
Python
from pprint import pprint import whoosh.index import whoosh.fields import whoosh.analysis import whoosh.query import whoosh.qparser import whoosh.writing from ferenda import util class FulltextIndex(object): """Open a fulltext index (creating it if it doesn't already exists). :param location: The file p...
Python
# -*- coding: utf-8 -*- from __future__ import unicode_literals import sys import os import re import xml.etree.cElementTree as ET from tempfile import mktemp import logging import six from ferenda import util from .elements import UnicodeElement, CompoundElement, OrdinalElement, serialize class Textbox(CompoundEle...
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import unicode_literals import sys import os import tempfile import shutil import time import json import codecs import collections import filecmp from io import BytesIO, StringIO from difflib import unified_diff try: from unittest.mock import Mock, patc...
Python
# -*- coding: utf-8 -*- from __future__ import unicode_literals import six if six.PY3: from urllib.parse import quote else: from urllib import quote def generic(d): querystring = "&".join([quote(k) + "=" + quote(v) for (k, v) in d.items()]) return "http://example.org/?%s" % querystring def url(d): ...
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import unicode_literals import functools import codecs import time import six from six import text_type as str from rdflib import Graph from ferenda import util from ferenda.errors import DocumentRemovedError, ParseError def timed(f): """Automatically...
Python
# -*- coding: utf-8 -*- from __future__ import unicode_literals """General library of small utility functions""" import os import sys import subprocess import codecs import shutil import locale import re from tempfile import mktemp from collections import namedtuple import filecmp import hashlib import datetime impor...
Python
# -*- coding: utf-8 -*- from __future__ import unicode_literals class URIFormatter(object): """Documentation goes here.""" def __init__(self, *formatters, **kwargs): self._formatters = dict(formatters) def format(self, parseresult): formatter = self.formatterfor(parseresult.getName()) ...
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import unicode_literals class ParseError(Exception): """Raised when :py:meth:`~ferenda.DocumentRepository.parse` fails in any way. """ pass class FSMStateError(ParseError): """Raised whenever the current state and the current symbol in a...
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import unicode_literals import pyparsing import six from ferenda.elements import LinkSubject, serialize class CitationParser(object): """Finds citations to documents and other resources in text strings. Each type of citation is specified by a ...
Python
"""General ready-made grammars for use with CitationParser.""" # -*- coding: utf-8 -*- from __future__ import unicode_literals from pyparsing import * ################################################################ # # ferenda.citationpatterns.url # # Adapted from http://pyparsing.wikispaces.com/file/view/urlparse_.p...
Python
import re from datetime import datetime import locale from ferenda import util from ferenda import Describer, DocumentRepository class W3Standards(DocumentRepository): alias = "w3c" start_url = "http://www.w3.org/TR/tr-status-all" document_url_regex = "http://www.w3.org/TR/(?P<year>\d{4})/REC-(?P<basefil...
Python
from ferenda import DocumentRepository class PEP(DocumentRepository): module_dir = "pep" start_url = "http://hg.python.org/peps" document_url_template = "http://hg.python.org/peps/file/tip/pep-%(basefile)s.txt" def download(self): hg_clone_path = os.sep.join(self.config.datadir, self.alias, 'c...
Python
# flake8: noqa from .w3c import W3Standards from .rfc import RFC from .pep import PEP
Python
# -*- coding: utf-8 -*- import re import os from datetime import datetime, date from itertools import islice import requests import requests.exceptions import six from rdflib import Graph,Literal from ferenda import DocumentRepository from ferenda.errors import DocumentRemovedError, ParseError from ferenda.decorators...
Python
#!/usr/bin/env python # -*- coding: iso-8859-1 -*- import sys import os import re import datetime from operator import attrgetter from ferenda import DocumentRepository from ferenda import util from ferenda import legaluri # from ferenda import LegalRef __version__ = (0, 1) __author__ = "Staffan Malmgren <staffan@to...
Python
# -*- coding: utf-8 -*- from ferenda import DocumentRepository import re class Kommitte(DocumentRepository): module_dir = "komm" start_url = "http://62.95.69.15/cgi-bin/thw?${HTML}=komm_lst&${OOHTML}=komm_doc&${SNHTML}=komm_err&${MAXPAGE}=26&${TRIPSHOW}=format%3DTHW&${BASE}=KOMM" source_encoding = "iso-88...
Python
#!/usr/bin/env python # -*- coding: iso-8859-1 -*- import re from . import Regeringen # are there other sources? www.sou.gov.se directs here, # anyway. Possibly # https://www.riksdagen.se/Webbnav/index.aspx?nid=3282, but it's # unsure whether they have any more information, or they just import # from regeringen.se (th...
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import unicode_literals,print_function """Hanterar (konsoliderade) f\xf6rfattningar i SFS fr\xe5n Regeringskansliet r\xe4ttsdatabaser. """ # system libraries (+ six) from collections import defaultdict from datetime import datetime, date from tempfile impor...
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import unicode_literals # Intermediate base class containing some small functionality useful # for handling data sources of swedish law. import os from datetime import datetime, date import difflib import re from rdflib import Literal, Namespace, URIRef, R...
Python
#!/usr/bin/env python # -*- coding: iso-8859-1 -*- import re from . import Regeringen # See SOU.py for discussion about possible other sources class Ds(Regeringen): module_dir = "ds" re_basefile_strict = re.compile(r'Ds (\d{4}:\d+)') re_basefile_lax = re.compile(r'(?:Ds|) ?(\d{4}:\d+)', re.IGNORECASE) ...
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- # # A abstract base class for fetching and parsing regulations from # various swedish government agencies. These PDF documents often have # a similar structure both graphically and linguistically, enabling us # to parse them in a generalized way. (Downloading them often req...
Python
# flake8: noqa from rdflib import Namespace RPUBL = Namespace('http://rinfo.lagrummet.se/ns/2008/11/rinfo/publ#') from .swedishlegalsource import SwedishLegalSource from .regeringen import Regeringen from .riksdagen import Riksdagen from .arn import ARN from .direktiv import Direktiv from .ds import Ds from .dv import ...
Python
#!/usr/bin/env python # -*- coding: iso-8859-1 -*- import sys import os import re import datetime from collections import deque, defaultdict import xml.etree.cElementTree as ET import xml.etree.ElementTree as PET from pprint import pprint from operator import itemgetter import subprocess from rdflib import Namespace, ...
Python
# flake8: noqa from .eurlexcaselaw import EurlexCaselaw from .eurlextreaties import EurlexTreaties
Python
# flake8: noqa from .keyword import Keyword from .skeleton import Skeleton from .wiki import Wiki
Python
# flake8: noqa from .citationparser import CitationParser from .uriformatter import URIFormatter from .describer import Describer from .layeredconfig import LayeredConfig from .pdfreader import PDFReader from .textreader import TextReader from .wordreader import WordReader from .triplestore import TripleStore from .ful...
Python
# -*- coding: utf-8 -*- from __future__ import unicode_literals from rdflib.extras.describer import Describer as OrigDescriber from rdflib import URIRef, Literal, RDF, Graph class Describer(OrigDescriber): """Extends the utility class :py:class:`rdflib.extras.describer.Describer` so that it reads values a...
Python
# -*- coding: utf-8 -*- """Utility functions for running various ferenda tasks from the command line, including registering classes in the configuration file. If you're using the :py:class:`~ferenda.DocumentRepository` API directly in your code, you'll probably only need :py:func:`makeresources`, :py:func:`frontpage` a...
Python