hideki nara avatar hideki nara committed da97e1b

inital codes

Comments (0)

Files changed (3)

Add a comment to this file

src/djpostal/management/__init__.py

Empty file added.

Add a comment to this file

src/djpostal/management/commands/__init__.py

Empty file added.

src/djpostal/management/commands/jpaddress.py

+# -*- coding: utf-8 -*-
+
+from django.core.management.base import BaseCommand, CommandError
+from django.contib.auth.models import User
+from optparse import make_option
+from datetime import datetime
+import commands
+import os
+import csv
+#
+from models import JpAddress
+
+class Command(BaseCommand):
+    args = ''
+    help = ''
+    option_list = BaseCommand.option_list + (
+        make_option('--url',
+            action='store',
+            dest='url',
+            default='http://www.post.japanpost.jp/zipcode/dl/kogaki/lzh/ken_all.lzh',
+            help='JP Address Data URL'),
+        make_option('--file',
+            action='store',
+            dest='file',
+            default='ken_all.csv',
+            help='JP Address Data File Name'),
+        )
+
+    def handle(self, *args, **options):
+        if os.path.exists( options['file'] ) == False:
+            print commands.getoutput( "curl %(url)s | lha x - " %  options )
+        if os.path.exists( options['file']+".utf8" ) == False:
+            print commands.getoutput( "nkf -w %(file)s > %(file)s.utf8" % options ) 
+
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.