[cc-commits] [SCM] A place to dump one-off scripts that might be useful to look at in the future. (branch master) updated. 742c2499a5767d99f971d29cc402f1e667b06aee
Gitosis User
git at gandi0.creativecommons.org
Tue Jan 24 16:58:18 EST 2012
The branch, master has been updated
via 742c2499a5767d99f971d29cc402f1e667b06aee (commit)
from ba5748cae8b394b7d9d68d074155a05a7d3f8c42 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 742c2499a5767d99f971d29cc402f1e667b06aee
Author: Christopher Allan Webber <cwebber at dustycloud.org>
Date: Tue Jan 24 16:00:09 2012 -0600
Some more throwaway scripts
-----------------------------------------------------------------------
Summary of changes (followed by patch):
clipboard_scraper.py | 20 ++++++++++++++++++++
convert_pofiles.py => remove_po_dupes.py | 19 +++++++++++--------
2 files changed, 31 insertions(+), 8 deletions(-)
create mode 100644 clipboard_scraper.py
copy convert_pofiles.py => remove_po_dupes.py (79%)
diff --git a/clipboard_scraper.py b/clipboard_scraper.py
new file mode 100644
index 0000000..acd69a4
--- /dev/null
+++ b/clipboard_scraper.py
@@ -0,0 +1,20 @@
+#!/usr/bin/env python
+
+import gtk
+
+
+def scrape_clipboard():
+ clipboard = gtk.clipboard_get()
+ targets = clipboard.wait_for_targets()
+
+ for target in ["text/html", "UTF8_STRING", "text"]:
+ if targets.count(target):
+ paste = clipboard.wait_for_contents(target)
+ print "found target type:", target
+ return paste.data
+
+ return None
+
+
+if __name__ == "__main__":
+ print scrape_clipboard()
diff --git a/convert_pofiles.py b/remove_po_dupes.py
similarity index 79%
copy from convert_pofiles.py
copy to remove_po_dupes.py
index f15d416..e515761 100644
--- a/convert_pofiles.py
+++ b/remove_po_dupes.py
@@ -14,22 +14,25 @@
# Convert pofiles from ${foo} style string substitutions to %(foo)s
# style for the great Jinja2 {% trans %} block conversion ;)
-import re
+import copy
import sys
-from babel.messages.pofile import read_po
from cc.i18n.tools.support import polib_wrapped_write_po
+from babel.messages.catalog import Catalog
+from babel.messages.pofile import read_po
def convert_pofile(filename):
- podata = file(filename, 'r').read()
- converted = re.sub(
- "\$\{?(.+?)\}", lambda x: "%(" + x.groups()[0] + ")s", podata)
- file(filename, 'w').write(converted)
pofile = read_po(file(filename, 'r'))
+
+ new_catalog = Catalog(
+ header_comment="",
+ locale=pofile.locale,
+ domain=pofile.domain)
+
for msg in pofile:
- msg.context = None
+ new_catalog[msg.id] = msg
- polib_wrapped_write_po(filename, pofile)
+ polib_wrapped_write_po(filename, new_catalog)
def main():
filenames = sys.argv[1:]
hooks/post-receive
--
A place to dump one-off scripts that might be useful to look at in the future.
More information about the cc-commits
mailing list