Re: [aur-dev] [PATCH 3/4] reformat

2011-04-06 Thread Rémy Oudompheng
On Tue 05 April 2011 at 17:54 -0700, elij wrote:
 - make the sql nicer and more readable
 - convert to spaces. who uses tabs in python!?

As far as I know, we use tabs in all of our Python projects.

-- 
Rémy.


Re: [aur-dev] [PATCH 3/4] reformat

2011-04-06 Thread elij
On Tue, Apr 5, 2011 at 11:25 PM, Rémy Oudompheng
remyoudomph...@gmail.com wrote:
 On Tue 05 April 2011 at 17:54 -0700, elij wrote:
 - make the sql nicer and more readable
 - convert to spaces. who uses tabs in python!?

 As far as I know, we use tabs in all of our Python projects.

Sorry to hear it.
:)


[aur-dev] [PATCH 3/4] reformat

2011-04-05 Thread elij
- make the sql nicer and more readable
- convert to spaces. who uses tabs in python!?
---
 support/schema/gendummydata.py |  248 
 1 files changed, 124 insertions(+), 124 deletions(-)

diff --git a/support/schema/gendummydata.py b/support/schema/gendummydata.py
index d424564..6ad4fb2 100755
--- a/support/schema/gendummydata.py
+++ b/support/schema/gendummydata.py
@@ -37,10 +37,10 @@ PKG_CMNTS = (1, 5) # min/max number of comments a 
package has
 CATEGORIES_COUNT = 17  # the number of categories from aur-schema
 VOTING= (0, .30)   # percentage range for package voting
 RANDOM_PATHS = (   # random path locations for package files
-   /usr/bin, /usr/lib, /etc, /etc/rc.d, /usr/share, /lib,
-   /var/spool, /var/log, /usr/sbin, /opt, /usr/X11R6/bin,
-   /usr/X11R6/lib, /usr/libexec, /usr/man/man1, /usr/man/man3,
-   /usr/man/man5, /usr/X11R6/man/man1, /etc/profile.d
+/usr/bin, /usr/lib, /etc, /etc/rc.d, /usr/share, /lib,
+/var/spool, /var/log, /usr/sbin, /opt, /usr/X11R6/bin,
+/usr/X11R6/lib, /usr/libexec, /usr/man/man1, /usr/man/man3,
+/usr/man/man5, /usr/X11R6/man/man1, /etc/profile.d
 )
 RANDOM_TLDS = (edu, com, org, net, tw, ru, pl, de, es)
 RANDOM_URL = (http://www.;, ftp://ftp.;, http://;, ftp://;)
@@ -57,14 +57,14 @@ logging.basicConfig(format=logformat, level=level)
 log = logging.getLogger()
 
 if len(sys.argv) != 2:
-   log.error(Missing output filename argument)
-   raise SystemExit
+log.error(Missing output filename argument)
+raise SystemExit
 
 # make sure the seed file exists
 #
 if not os.path.exists(SEED_FILE):
-   log.error(Please install the 'words' Arch package)
-   raise SystemExit
+log.error(Please install the 'words' Arch package)
+raise SystemExit
 
 # track what users/package names have been used
 #
@@ -75,16 +75,16 @@ user_keys = []
 # some functions to generate random data
 #
 def genVersion():
-   ver = []
-   ver.append(%d % random.randrange(0,10))
-   ver.append(%d % random.randrange(0,20))
-   if random.randrange(0,2) == 0:
-   ver.append(%d % random.randrange(0,100))
-   return ..join(ver) + -u%d % random.randrange(1,11)
+ver = []
+ver.append(%d % random.randrange(0,10))
+ver.append(%d % random.randrange(0,20))
+if random.randrange(0,2) == 0:
+ver.append(%d % random.randrange(0,100))
+return ..join(ver) + -u%d % random.randrange(1,11)
 def genCategory():
-   return random.randrange(0,CATEGORIES_COUNT)
+return random.randrange(0,CATEGORIES_COUNT)
 def genUID():
-   return seen_users[user_keys[random.randrange(0,len(user_keys))]]
+return seen_users[user_keys[random.randrange(0,len(user_keys))]]
 
 
 # load the words, and make sure there are enough words for users/pkgs
@@ -94,25 +94,25 @@ fp = open(SEED_FILE, r)
 contents = fp.readlines()
 fp.close()
 if MAX_USERS  len(contents):
-   MAX_USERS = len(contents)
+MAX_USERS = len(contents)
 if MAX_PKGS  len(contents):
-   MAX_PKGS = len(contents)
+MAX_PKGS = len(contents)
 if len(contents) - MAX_USERS  MAX_PKGS:
-   need_dupes = 0
+need_dupes = 0
 else:
-   need_dupes = 1
+need_dupes = 1
 
 # select random usernames
 #
 log.debug(Generating random user names...)
 user_id = USER_ID
 while len(seen_users)  MAX_USERS:
-   user = random.randrange(0, len(contents))
-   word = contents[user].replace(', ).replace(.,).replace( , _)
-   word = word.strip().lower()
-   if not seen_users.has_key(word):
-   seen_users[word] = user_id
-   user_id += 1
+user = random.randrange(0, len(contents))
+word = contents[user].replace(', ).replace(.,).replace( , _)
+word = word.strip().lower()
+if not seen_users.has_key(word):
+seen_users[word] = user_id
+user_id += 1
 user_keys = seen_users.keys()
 
 # select random package names
@@ -120,17 +120,17 @@ user_keys = seen_users.keys()
 log.debug(Generating random package names...)
 num_pkgs = PKG_ID
 while len(seen_pkgs)  MAX_PKGS:
-   pkg = random.randrange(0, len(contents))
-   word = contents[pkg].replace(', ).replace(.,).replace( , _)
-   word = word.strip().lower()
-   if not need_dupes:
-   if not seen_pkgs.has_key(word) and not seen_users.has_key(word):
-   seen_pkgs[word] = num_pkgs
-   num_pkgs += 1
-   else:
-   if not seen_pkgs.has_key(word):
-   seen_pkgs[word] = num_pkgs
-   num_pkgs += 1
+pkg = random.randrange(0, len(contents))
+word = contents[pkg].replace(', ).replace(.,).replace( , _)
+word = word.strip().lower()
+if not need_dupes:
+if not seen_pkgs.has_key(word) and not seen_users.has_key(word):
+seen_pkgs[word] = num_pkgs
+num_pkgs += 1
+else:
+if not seen_pkgs.has_key(word):
+seen_pkgs[word] = num_pkgs
+  

Re: [aur-dev] [PATCH 3/4] reformat

2011-04-05 Thread elij
On Tue, Apr 5, 2011 at 6:54 PM, Dan McGee dpmc...@gmail.com wrote:
 On Tue, Apr 5, 2011 at 7:54 PM, elij elij...@gmail.com wrote:
 - make the sql nicer and more readable
 - convert to spaces. who uses tabs in python!?
 -1. These should not be done in the same patch.

 -Dan

They were both solely formatting changes, and changed no underlying
logic or behavior. It seemed reasonable for me to include them both in
the same patch.