Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed translation ugettext to lazy version #2

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
sudo: false
language: python
python:
- "2.7"
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ dev: $(DJANGO)
check: $(TEST) $(FLAKE8) $(PYLINT)
$(TEST)
$(FLAKE8)
$(PYLINT)
$(PYLINT) --rcfile=pylint.rc rdflib_django


snapshot: $(BUILDOUT) clean check
Expand Down
29 changes: 13 additions & 16 deletions buildout.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,29 @@ eggs =
rdflib

versions = versions
extensions =
buildout.dumppickedversions

src-directory = src/rdflib_django
develop = .
unzip = true

[versions]
Django=1.4.1
collective.recipe.omelette = 0.15
django-extensions = 0.9
djangorecipe = 1.3
flake8 = 1.4
isodate = 0.4.8
logilab-astng = 0.24.0
logilab-common = 0.58.1
pylint = 0.25.2
rdflib = 3.2.2
setuptools = 0.6c12dev-r88846
zc.buildout = 1.6.3
zc.recipe.egg = 1.3.2
Django=1.8.3
collective.recipe.omelette = 0.16
django-extensions = 1.5.5
djangorecipe = 2.1.1
flake8 = 2.4.1
isodate = 0.5.1
logilab-astng = 0.24.3
logilab-common = 1.0.2
pylint = 1.4.4
rdflib = 4.2.0
setuptools = 12.0.5
zc.buildout = 2.4.0
zc.recipe.egg = 2.0.2

[django]
recipe = djangorecipe
project = ${buildout:name}
projectegg = ${buildout:name}
settings = testsettings
eggs = ${buildout:eggs}
test = ${buildout:name}
Expand Down
2 changes: 1 addition & 1 deletion src/rdflib_django/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class URIField(models.CharField):
description = "Field for storing URIRefs and BNodes."

def __init__(self, *args, **kwargs):
if not 'max_length' in kwargs:
if 'max_length' not in kwargs:
kwargs['max_length'] = 500
super(URIField, self).__init__(*args, **kwargs)

Expand Down
2 changes: 1 addition & 1 deletion src/rdflib_django/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class NamespaceForm(forms.ModelForm):
Form for editing namespaces.
"""

class Meta:
class Meta(object):
model = models.NamespaceModel
fields = ('prefix', 'uri')

Expand Down
14 changes: 6 additions & 8 deletions src/rdflib_django/management/commands/rdf_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,14 @@ class Command(BaseCommand):

option_list = BaseCommand.option_list + (
make_option('--context', '-c', type='string', dest='context',
help='Only RDF data from the context with this identifier will be exported. If not specified, a new blank ' +
'context is created.'),
help='Only RDF data from the context with this identifier will be exported. If not specified, a new blank context is created.'),

make_option('--store', '-s', type='string', dest='store',
help='RDF data will be exported from the store with this identifier. If not specified, the default store ' +
'is used.'),
help='RDF data will be exported from the store with this identifier. If not specified, the default store is used.'),

make_option('--format', '-f', type='string', dest='format', default='xml',
help='Format of the RDF data. This option accepts all formats allowed by rdflib. Defaults to xml.')
)
make_option('--format', '-f', type='string', dest='format',
default='xml',
help='Format of the RDF data. This option accepts all formats allowed by rdflib. Defaults to xml.'))

help = """Exports an RDF resource.

Expand All @@ -45,5 +43,5 @@ def handle(self, *args, **options):
else:
graph = utils.get_conjunctive_graph(store_id)

#noinspection PyUnresolvedReferences
# noinspection PyUnresolvedReferences
graph.serialize(target, format=options.get('format'))
25 changes: 13 additions & 12 deletions src/rdflib_django/management/commands/rdf_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,24 @@
from rdflib_django import utils


atomic_decorator = getattr(transaction, 'atomic', None) or getattr(transaction, 'commit_on_success')


class Command(BaseCommand):
"""
Command object for importing RDF.
"""

option_list = BaseCommand.option_list + (
make_option('--store', '-s', type='string', dest='store',
help='RDF data will be imported into the store with this identifier. If not specified, the default store ' +
'is used.'),
help='RDF data will be imported into the store with this identifier. If not specified, the default store is used.'),

make_option('--context', '-c', type='string', dest='context',
help='RDF data will be imported into a context with this identifier. If not specified, a new blank ' +
'context is created.'),
help='RDF data will be imported into a context with this identifier. If not specified, a new blank context is created.'),

make_option('--format', '-f', type='string', dest='format', default='xml',
help='Format of the RDF data. This option accepts all formats allowed by rdflib. Defaults to xml.')
)
make_option('--format', '-f', type='string', dest='format',
default='xml',
help='Format of the RDF data. This option accepts all formats allowed by rdflib. Defaults to xml.'))

help = """Imports an RDF resource.

Expand All @@ -37,7 +38,7 @@ class Command(BaseCommand):
""".format(sys.argv[0])
args = 'file-or-resource'

@transaction.commit_on_success
@atomic_decorator
def handle(self, *args, **options):
if not args:
raise CommandError("No file or resource specified.")
Expand All @@ -48,7 +49,7 @@ def handle(self, *args, **options):
source = args[0]

if info:
print("Parsing {0}".format(source))
print "Parsing {0}".format(source)

intermediate = Graph()
try:
Expand All @@ -57,14 +58,14 @@ def handle(self, *args, **options):
raise CommandError(e)

if info:
print("Parsed {0} triples".format(len(intermediate)))
print "Parsed {0} triples".format(len(intermediate))

identifier = URIRef(context_id) if context_id else BNode()
graph = utils.get_named_graph(identifier, store_id=store_id)

if info:
print("Storing {0} triples".format(len(intermediate)))
print "Storing {0} triples".format(len(intermediate))
for triple in intermediate:
graph.add(triple)
if info:
print("Done")
print "Done"
12 changes: 6 additions & 6 deletions src/rdflib_django/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
to be used for publishing resources.
"""
from django.db import models
from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy as _
from django_extensions.db.fields import UUIDField
from rdflib_django import fields

Expand All @@ -17,12 +17,12 @@ class NamedGraph(models.Model):

identifier = fields.URIField(verbose_name=_("Identifier"), unique=True)

class Meta:
class Meta: # pylint: disable=C1001
verbose_name = _("named graph")
verbose_name_plural = _("named graphs")

def __unicode__(self):
return u"{0}".format(self.identifier, "identifier")
return u"{0}".format(self.identifier)


class NamespaceModel(models.Model):
Expand All @@ -38,7 +38,7 @@ class NamespaceModel(models.Model):
uri = models.CharField(max_length=500, verbose_name=_("URI"), db_index=True, unique=True)
fixed = models.BooleanField(verbose_name=_("Fixed"), editable=False, default=False)

class Meta:
class Meta: # pylint: disable=C1001
verbose_name = _("namespace")
verbose_name_plural = _("namespaces")

Expand All @@ -57,7 +57,7 @@ class URIStatement(models.Model):
object = fields.URIField(_("Object"), db_index=True)
context = models.ForeignKey(NamedGraph, verbose_name=_("Context"))

class Meta:
class Meta: # pylint: disable=C1001
unique_together = ('subject', 'predicate', 'object', 'context')

def __unicode__(self):
Expand All @@ -81,7 +81,7 @@ class LiteralStatement(models.Model):
object = fields.LiteralField(_("Object"), db_index=True)
context = models.ForeignKey(NamedGraph, verbose_name=_("Context"))

class Meta:
class Meta: # pylint: disable=C1001
unique_together = ('subject', 'predicate', 'object', 'context')

def __unicode__(self):
Expand Down
6 changes: 3 additions & 3 deletions src/rdflib_django/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def _get_named_graph(context):
return models.NamedGraph.objects.get_or_create(identifier=context.identifier)[0]


class DjangoStore(rdflib.store.Store):
class DjangoStore(rdflib.store.Store): # pylint: disable=abstract-method
"""
RDFlib Store implementation the uses Django Models for storage and retrieval.

Expand Down Expand Up @@ -170,7 +170,7 @@ def remove(self, (s, p, o), context=None):
if o:
filter_parameters['object'] = o

query_sets = [qs.filter(**filter_parameters) for qs in query_sets] # pylint: disable=W0142
query_sets = [qs.filter(**filter_parameters) for qs in query_sets]

for qs in query_sets:
qs.delete()
Expand All @@ -192,7 +192,7 @@ def triples(self, (s, p, o), context=None):
if o:
filter_parameters['object'] = o

query_sets = [qs.filter(**filter_parameters) for qs in query_sets] # pylint: disable=W0142
query_sets = [qs.filter(**filter_parameters) for qs in query_sets]

for qs in query_sets:
for statement in qs:
Expand Down
7 changes: 4 additions & 3 deletions src/rdflib_django/test_rdflib.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,8 @@ def testTriples(self):

self.assertEquals(set(c.subject_objects(self.hates)), {(self.bob, self.pizza), (self.bob, self.michel)})
self.assertEquals(set(c.subject_objects(self.likes)),
{(self.tarek, self.cheese), (self.michel, self.cheese), (self.michel, self.pizza), (self.bob, self.cheese), (self.tarek, self.pizza)})
{(self.tarek, self.cheese), (self.michel, self.cheese), (self.michel, self.pizza), (self.bob, self.cheese),
(self.tarek, self.pizza)})

self.assertEquals(set(c.predicate_objects(self.michel)), {(self.likes, self.cheese), (self.likes, self.pizza)})
self.assertEquals(set(c.predicate_objects(self.bob)), {(self.likes, self.cheese), (self.hates, self.pizza), (self.hates, self.michel)})
Expand All @@ -538,8 +539,8 @@ def testTriples(self):
self.assertEquals(set(c.subject_predicates(self.michel)), {(self.bob, self.hates)})

self.assertEquals(set(c), {(self.bob, self.hates, self.michel), (self.bob, self.likes, self.cheese), (self.tarek, self.likes, self.pizza),
(self.michel, self.likes, self.pizza), (self.michel, self.likes, self.cheese), (self.bob, self.hates, self.pizza),
(self.tarek, self.likes, self.cheese)})
(self.michel, self.likes, self.pizza), (self.michel, self.likes, self.cheese), (self.bob, self.hates, self.pizza),
(self.tarek, self.likes, self.cheese)})

# remove stuff and make sure the graph is empty again
self.removeStuff()
Expand Down
4 changes: 2 additions & 2 deletions src/rdflib_django/test_seq.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def testSeq(self):
"""
items = self.store.seq(URIRef("http://example.org/Seq"))
self.assertEquals(len(items), 6)
self.assertEquals(items[-1].concrete(), URIRef("http://example.org/six"))
self.assertEquals(items[2].concrete(), URIRef("http://example.org/three"))
self.assertEquals(items[-1], URIRef("http://example.org/six"))
self.assertEquals(items[2], URIRef("http://example.org/three"))
# just make sure we can serialize
self.store.serialize()

Expand Down
8 changes: 4 additions & 4 deletions src/rdflib_django/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ def suite():
s = unittest.TestSuite()
s.addTest(doctest.DocTestSuite(rdflib_django))
s.addTest(doctest.DocTestSuite(store))
s.addTest(unittest.findTestCases(test_store))
s.addTest(unittest.findTestCases(test_rdflib))
s.addTest(unittest.findTestCases(test_seq))
s.addTest(unittest.findTestCases(test_namespaces))
s.addTest(unittest.findTestCases(test_store)) # pylint: disable=no-member
s.addTest(unittest.findTestCases(test_rdflib)) # pylint: disable=no-member
s.addTest(unittest.findTestCases(test_seq)) # pylint: disable=no-member
s.addTest(unittest.findTestCases(test_namespaces)) # pylint: disable=no-member
return s
2 changes: 2 additions & 0 deletions src/rdflib_django/testsettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,5 @@
},
}
}

SECRET_KEY = os.urandom(32)
5 changes: 2 additions & 3 deletions src/rdflib_django/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@
admin.autodiscover()

urlpatterns = patterns('',
(r'^admin/doc/', include('django.contrib.admindocs.urls')),
(r'^admin/', include(admin.site.urls)),
)
(r'^admin/doc/', include('django.contrib.admindocs.urls')),
(r'^admin/', include(admin.site.urls)),)