From: Eevee Date: Sun, 4 Oct 2009 22:32:07 +0000 (-0700) Subject: Augh! Removed trailing whitespace. X-Git-Url: http://git.veekun.com/zzz-floof.git/commitdiff_plain/5fa3452111e4f29afacdec939b31ae7bfe1c5049 Augh! Removed trailing whitespace. --- diff --git a/ez_setup.py b/ez_setup.py index d24e845..e33744b 100644 --- a/ez_setup.py +++ b/ez_setup.py @@ -92,7 +92,7 @@ def use_setuptools( try: import pkg_resources except ImportError: - return do_download() + return do_download() try: pkg_resources.require("setuptools>="+version); return except pkg_resources.VersionConflict, e: diff --git a/floof/config/environment.py b/floof/config/environment.py index 3470f2a..cf6c77e 100644 --- a/floof/config/environment.py +++ b/floof/config/environment.py @@ -35,7 +35,7 @@ def load_environment(global_conf, app_conf): input_encoding='utf-8', output_encoding='utf-8', imports=['from webhelpers.html import escape'], default_filters=['escape']) - + # Setup the SQLAlchemy^W Elixir database engine engine = engine_from_config(config, 'sqlalchemy.') if model.elixir.options_defaults.get('autoload'): @@ -46,6 +46,6 @@ def load_environment(global_conf, app_conf): else: # Non-reflected tables model.init_model(engine) - + # CONFIGURATION OPTIONS HERE (note: all config options will override # any Pylons config options) diff --git a/floof/controllers/art.py b/floof/controllers/art.py index e988c7b..8d40321 100644 --- a/floof/controllers/art.py +++ b/floof/controllers/art.py @@ -19,8 +19,8 @@ class ArtController(BaseController): def new(self): """ New Art! """ return render("/art/new.mako") - - + + def upload(self): print "PARAMS", request.params Art(uploaded_by=c.user, **request.params) @@ -30,7 +30,7 @@ class ArtController(BaseController): def show(self, id): c.art = Art.get(id) return render("/art/show.mako") - + def tag(self, id): art = Art.get(id) art.add_tags(request.params["tags"], c.user) diff --git a/floof/forms/validators/unique.py b/floof/forms/validators/unique.py index 4fb3c8f..9b94869 100644 --- a/floof/forms/validators/unique.py +++ b/floof/forms/validators/unique.py @@ -1,5 +1,5 @@ from formencode import * -from formencode import validators +from formencode import validators import pylons _ = validators._ # dummy translation string @@ -14,29 +14,29 @@ class FilteringSchema(Schema): # Model-based validators class Unique(validators.FancyValidator): - + """ Checks if given value is unique to the model.Will check the state: if state object is the same as the instance, or the state contains a property with the same name as the context name. For example: - + validator = validators.Unique(model.NewsItem, "title", context_name="news_item") - + This will check if there is an existing instance with the same "title". If there is a matching instance, will check if the state passed into the validator is the same instance, or if the state contains a property "news_item" which is the same instance. """ - + __unpackargs__ = ('model', 'attr', "model_name", "context_name", "attribute_name") messages = { 'notUnique' : _("%(modelName)s already exists with this %(attrName)s"), } - + model_name = "Item" attribute_name = None context_name = None - + def validate_python(self, value, state): instance = self.model.get_by(**{self.attr : value}) if instance: @@ -44,9 +44,9 @@ class Unique(validators.FancyValidator): if state != instance and \ getattr(state, context_name, None) != instance: attr_name = self.attribute_name or self.attr - raise Invalid(self.message('notUnique', state, + raise Invalid(self.message('notUnique', state, modelName=self.model_name, - attrName=attr_name), + attrName=attr_name), value, state) - + validators.Unique = Unique diff --git a/floof/lib/file_storage.py b/floof/lib/file_storage.py index 4469394..90561d0 100644 --- a/floof/lib/file_storage.py +++ b/floof/lib/file_storage.py @@ -20,21 +20,21 @@ guess_type(temp.filename)[0] def get_path(space, hash): return "/" + os.path.join( space, hash[:2], hash[2:] ) - -def save_file(space, temp): - + +def save_file(space, temp): + dest_root = os.path.join( config['app_conf']['static_root'], space ) - + # we don't know where we're going to save this stuff yet, # so I guess we'll write it to another tempfile. One we know the path of. - # I'm assuming the tempfile we get from pylons is set to delete itself + # I'm assuming the tempfile we get from pylons is set to delete itself # when it closes, and has no visible path. Maybe I'm wrong? intermediate_file_descriptor, intermediate_path = tempfile.mkstemp() - + # that function gives me an integer file descriptor for some reason. intermediate_file = os.fdopen(intermediate_file_descriptor, "wb") - + sha1 = hashlib.sha1() while 1: data = temp.file.read(chunk_size) diff --git a/floof/lib/fixtures.py b/floof/lib/fixtures.py index 0b2f3ec..8cec8ff 100644 --- a/floof/lib/fixtures.py +++ b/floof/lib/fixtures.py @@ -7,15 +7,15 @@ from floof import model as model """ This module can be used for loading data into your models, for example when setting up default application data, -unit tests, JSON export/import and importing/exporting legacy data. Data is serialized to and from the JSON format. +unit tests, JSON export/import and importing/exporting legacy data. Data is serialized to and from the JSON format. """ VALID_FIXTURE_FILE_EXTENSIONS = ['.json'] def load_data(model, filename=None, base_dir=None): - """Installs provided fixture files into given model. Filename may be directory, file or list of dirs or files. If filename is - None, assumes that source file is located in fixtures/model_module_name/model_tablename.yaml of your application directory, - for example MyProject/fixtures/news/newsitems.yaml. The base_dir argument is the top package of the application unless + """Installs provided fixture files into given model. Filename may be directory, file or list of dirs or files. If filename is + None, assumes that source file is located in fixtures/model_module_name/model_tablename.yaml of your application directory, + for example MyProject/fixtures/news/newsitems.yaml. The base_dir argument is the top package of the application unless specified. You can also pass the name of a table instead of a model class.""" if type(model) is types.StringType: @@ -28,17 +28,17 @@ def load_data(model, filename=None, base_dir=None): def load_data_to_table(table, filename=None, base_dir=None): """Installs data directly into a table. Useful if table does not have a corresponding model, for example a many-to-many join table. """ - + if filename is None: filename = _default_fixture_path_for_table(table, base_dir) _load_data_to_table(table, filename) - + def dump_data(model, filename=None, **params): - """Dumps data to given destination. Params are optional arguments for selecting data. If filename is None, assumes that destination - file is located in fixtures/model_module_name/model_name_lowercase.yaml of your application directory, for example + """Dumps data to given destination. Params are optional arguments for selecting data. If filename is None, assumes that destination + file is located in fixtures/model_module_name/model_name_lowercase.yaml of your application directory, for example MyProject/fixtures/news/newsitem.yaml. """ - + if filename is None: filename = _default_fixture_path_for_model(model) _dump_data_to_file(model, filename, **params) @@ -52,7 +52,7 @@ def _default_fixture_path_for_model(model, base_dir=None): module_dirs = model.__module__.split('.', 2)[-1].split('.') for dir in module_dirs: path = os.path.join(path, dir) - return os.path.join(path, model.table.name + '.json') + return os.path.join(path, model.table.name + '.json') def _default_fixture_path_for_table(table, base_dir=None): if base_dir is None: @@ -66,14 +66,14 @@ def _default_fixture_path_for_table(table, base_dir=None): def _is_fixture_file(filename): basename, ext = os.path.splitext(filename) return (ext.lower() in VALID_FIXTURE_FILE_EXTENSIONS) - + def _load_data_from_dir(model, dirname): for dirpath, dirnames, filenames in os.walk(dirname): for filename in filenames: _load_data_from_file(model, filename) - + def _load_data_from_file(model, filename): - if not _is_fixture_file(filename): + if not _is_fixture_file(filename): return fp = file(filename, 'r') data = simplejson.load(fp) @@ -86,11 +86,11 @@ def _load_data_from_file(model, filename): elif type(data) is types.DictType: retval = {} for key, item in data.iteritems(): - retval[key] = _load_instance_from_dict(model, item) + retval[key] = _load_instance_from_dict(model, item) return retval def _load_data_to_table(tablename, filename): - if not _is_fixture_file(filename): + if not _is_fixture_file(filename): return fp = file(filename, 'r') data = simplejson.load(fp) @@ -104,7 +104,7 @@ def _load_data_to_table(tablename, filename): for key, item in data.iteritems(): table.insert(item).execute() return data - + def _dump_data_to_file(model, filename, **params): if params: queryset = model.select_by(**params) @@ -116,9 +116,9 @@ def _dump_data_to_file(model, filename, **params): fp = file(filename, 'w') simplejson.dump(data, fp) fp.close() - + def _load_instance_from_dict(model, dict): - if not dict: return + if not dict: return instance = model() fields = model._descriptor.fields.keys() for k, v in dict.iteritems(): @@ -135,5 +135,5 @@ def _dump_instance_to_dict(instance): for field in fields: d[field] = getattr(instance, field) return d - + __all__ = ['load_data', 'dump_data'] diff --git a/floof/lib/helpers.py b/floof/lib/helpers.py index 84c3394..28e9176 100644 --- a/floof/lib/helpers.py +++ b/floof/lib/helpers.py @@ -21,7 +21,7 @@ def get_object_or_404(model, **kw): from pylons.controllers.util import abort """ Returns object, or raises a 404 Not Found is object is not in db. - Uses elixir-specific `get_by()` convenience function (see elixir source: + Uses elixir-specific `get_by()` convenience function (see elixir source: http://elixir.ematia.de/trac/browser/elixir/trunk/elixir/entity.py#L1082) Example: user = get_object_or_404(model.User, id = 1) """ diff --git a/floof/model/art.py b/floof/model/art.py index 66cbe0b..fd80d93 100644 --- a/floof/model/art.py +++ b/floof/model/art.py @@ -20,7 +20,7 @@ class Art(Entity): original_filename = Field(Unicode(120)) hash = Field(String) - uploaded_by = ManyToOne('User') + uploaded_by = ManyToOne('User') tags = OneToMany('Tag') # def __init__(self, **kwargs): @@ -35,7 +35,7 @@ class Art(Entity): def set_file(self, file): self.hash = save_file("art", file) - + file = property(get_path, set_file) def get_path(self): @@ -77,11 +77,11 @@ class Tag(Entity): if not self.tagtext: return "(broken)" return unicode(self.tagtext) - - + + class TagText(Entity): text = Field(Unicode(50)) # gotta enforce this somehow tags = OneToMany('Tag') - + def __unicode__(self): return self.text \ No newline at end of file diff --git a/floof/tests/__init__.py b/floof/tests/__init__.py index 68cb322..fc14a48 100644 --- a/floof/tests/__init__.py +++ b/floof/tests/__init__.py @@ -73,7 +73,7 @@ def teardown(): class TestModel(TestCase): def setUp(self): setup_all(True) - + def tearDown(self): drop_all(engine) diff --git a/floof/tests/functional/test_elixir.py b/floof/tests/functional/test_elixir.py index bd0228b..1c907f0 100644 --- a/floof/tests/functional/test_elixir.py +++ b/floof/tests/functional/test_elixir.py @@ -10,4 +10,4 @@ class TestElixir(TestModel): def test_session(self): assert Session.connection().dialect.name is 'sqlite' - +