summaryrefslogtreecommitdiff
path: root/archivist
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.net>2017-02-26 17:29:56 +0100
committerRené 'Necoro' Neumann <necoro@necoro.net>2017-02-26 17:29:56 +0100
commit413680326f4c1e6fb0e79bda70ec13533903078d (patch)
tree7d1e8164530e20448c04f591f5e7abad621fe8ee /archivist
parent74c99ddeb640b487ab4cdaf5dcb044bbffb1a778 (diff)
downloadarchivist-413680326f4c1e6fb0e79bda70ec13533903078d.tar.gz
archivist-413680326f4c1e6fb0e79bda70ec13533903078d.tar.bz2
archivist-413680326f4c1e6fb0e79bda70ec13533903078d.zip
Some repr and str improvements on the model
Diffstat (limited to '')
-rw-r--r--archivist/model.py28
1 files changed, 25 insertions, 3 deletions
diff --git a/archivist/model.py b/archivist/model.py
index 656926c..79b0514 100644
--- a/archivist/model.py
+++ b/archivist/model.py
@@ -51,6 +51,14 @@ class Prefix(BaseModel):
def __str__ (self):
return self.name
+ def __repr__ (self):
+ if self.builtin:
+ ext = ' (bp)' if self.pseudo else ' (b)'
+ else:
+ ext = ''
+
+ return "<%s %s%s>" % (self.__class__.__name__, self.name, ext)
+
@table
class Tag(BaseModel):
name = CharField()
@@ -59,18 +67,29 @@ class Tag(BaseModel):
@hybrid_method
def matches(self, prefix, name):
- return (self.prefix == prefix) & (self.name == name)
+ if isinstance(prefix, Prefix):
+ prefix = prefix.name
+
+ return (self.prefix_id == prefix) & (self.name == name)
class Meta:
indexes = [
(('name', 'prefix'), True)
]
+ def prefixed_name(self):
+ if self.prefix_id:
+ return "%s:%s" % (self.prefix_id, self.name)
+ else:
+ return self.name
+
def __str__(self):
- prefix = self.prefix.name + ':' if self.prefix else ''
description = ' -- ' + self.description if self.description else ''
- return prefix + self.name + description
+ return self.prefixed_name() + description
+
+ def __repr__(self):
+ return "<%s (#%d) %s>" % (self.__class__.__name__, self.id, self.prefixed_name())
@table
class DocumentTag(BaseModel):
@@ -87,3 +106,6 @@ class TagImplications(BaseModel):
class Meta:
primary_key = CompositeKey('tag', 'implies_tag')
+
+ def __repr__(self):
+ return "<%s %d --> %d>" % (self.__class__.__name__, self.tag_id, self.implies_tag_id)
s is especially needed, as YAML uses indentation for structures. Options set: - filetype to YAML (else 'conf' is infered) - set the number of spaces a tab is to 2 - expandtab -- do not insert \t but spaces 2010-12-01Encode the folder in UTF7Lucas Nussbaum1-1/+17 Patch from René 'Necoro' Neumann <lists@necoro.eu>, who writes: > I wanted to wrap the folder name in a call to > "Net::IMAP::encode_utf7" > to allow special characters like umlauts in the folder name (see the > attached patch). > > Problem is, that the encode_utf7 (and the decode_utf7 FWIW) uses the > 'String::force_encoding' method, which some googling shows to be in > Ruby1.9 but not 1.8. 2010-12-01robustify config parsingLucas Nussbaum1-11/+22 2010-11-30Also add reupload_if_updated for MaildirsLucas Nussbaum1-1/+4 2010-11-30Add a reupload_if_updated option (default: true)Lucas Nussbaum4-8/+20 Following a discussion on feed2imap-devel, add a reupload_if_updated option. When set to false, if an item is updated, but was previously removed from the IMAP server, it is no longer re-uploaded. Also fix some config file parsing bugs for the disable-ssl-verification and include-images options. I should really switch to another way to describe F2I config... 2010-07-05Patch to use feed item pubDate in Maildir file namesBernie Maier1-6/+10 Hi! I've just subscribed to the list, having downloaded feed2imap a few days ago. Since I want to just write RSS feeds to a local Maildir, this looked like just what I needed. Unfortunately, the release 1.0 version seems to randomise the order of the feed items when doing the first fetch for a new feed. Looking at maildir.rb, there is a "TODO: handle `date'" comment and it looks like the code is just generating maildir filenames using the timestamp at the time the items are being written into the maildir. Since all the initial items are written at the same time, and the maildir file name has a random element, this loses the original ordering from the mail feed. The solution is to use the timestamp corresponding to the pubDate in the feed item as the initial component of the maildir file name. Also, instead of using a random integer to force uniqueness in the second component of the file name, I think it is better to use a sequence number for each feed item, which will still be unique for the feed and also preserve item order. My patch follows (it's the first piece of Ruby code I've ever written / modified)... Cheers, Bernie 2010-04-18update websiteLucas Nussbaum2-2/+15 2010-04-18prepare releaseLucas Nussbaum4-5/+5 2010-04-18provide a way to disable SSL certificate verificationLucas Nussbaum4-1/+12 2010-04-18update changelogLucas Nussbaum1-0/+4 2010-04-18Update rubyimap.rbLucas Nussbaum1-5/+38 Update rubyimap.rb to upstream revision 27336 2010-03-17Document the maildir targetSandra Snan3-5/+5 I looked for a good feed to maildir program, and I couldn’t find one. Turns out, by looking at feed2imaps source code, that it has that function. So here’s a documentation patch so it’s easier to find. This patch shouldn’t touch any code. Generated by git. Sandra Signed-off-by: Sandra Snan <sandra.snan@handgranat.org> 2009-12-26Avoid using "acme.com"Lucas Nussbaum4-10/+19 Patch from Guido Berhoerster <guido@berhoerster.name>: Hello, here is a small patch that avoids using the valid(!) domain "acme.com" for generating message ids and email addresses. It adds a new global configuration option "default-email" which will be used in case a feed does provide one, currently feed2imap resorts to "feed2imap@acme.com". If this configuration option is not given it will basically default to <logname>@<hostname> as returned by Etc.getlogin and Socket.gethostname. Yours, 2009-09-04fix to use Message-Id instead of X-CacheIndexLucas Nussbaum1-5/+2 2009-09-03added the forth arg to ConfigFeed::new for maildirLucas Nussbaum1-1/+1