mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-13 08:01:09 +00:00
- Add functions mkdir and readlist.
This commit is contained in:
commit
91f62881df
32
common.py
32
common.py
@ -3,6 +3,7 @@
|
|||||||
# ubuntu-dev-tools package.
|
# ubuntu-dev-tools package.
|
||||||
#
|
#
|
||||||
# Copyright (C) 2008 Jonathan Patrick Davies <jpds@ubuntu.com>
|
# Copyright (C) 2008 Jonathan Patrick Davies <jpds@ubuntu.com>
|
||||||
|
# Copyright (C) 2008 Siegfried-Angel Gevatter Pujals <rainct@ubuntu.com>
|
||||||
#
|
#
|
||||||
# Some of the functions are based upon code written by Martin Pitt
|
# Some of the functions are based upon code written by Martin Pitt
|
||||||
# <martin.pitt@ubuntu.com> and Kees Cook <kees@ubuntu.com>.
|
# <martin.pitt@ubuntu.com> and Kees Cook <kees@ubuntu.com>.
|
||||||
@ -29,6 +30,37 @@ import os.path
|
|||||||
import sys
|
import sys
|
||||||
import urllib2
|
import urllib2
|
||||||
|
|
||||||
|
def mkdir(directory):
|
||||||
|
""" Create the given directory and all its parents recursively, but don't
|
||||||
|
raise an exception if it already exists. """
|
||||||
|
|
||||||
|
path = [x for x in directory.split('/') if x]
|
||||||
|
|
||||||
|
for i in xrange(len(path)):
|
||||||
|
current_path = '/' + '/'.join(path[:i+1])
|
||||||
|
if not os.path.isdir(current_path):
|
||||||
|
os.mkdir(current_path)
|
||||||
|
|
||||||
|
def readlist(filename, uniq=True):
|
||||||
|
""" Read a list of words from the indicated file. """
|
||||||
|
|
||||||
|
if not os.path.isfile(filename):
|
||||||
|
print 'File "%s" does not exist.' % filename
|
||||||
|
return False
|
||||||
|
|
||||||
|
content = open(filename).read().replace('\n', ' ').replace(',', ' ')
|
||||||
|
|
||||||
|
if not content.strip():
|
||||||
|
print 'File "%s" is empty.' % filename
|
||||||
|
return False
|
||||||
|
|
||||||
|
items = [item for item in content.split() if item]
|
||||||
|
|
||||||
|
if uniq:
|
||||||
|
items = list(set(items))
|
||||||
|
|
||||||
|
return items
|
||||||
|
|
||||||
def prepareLaunchpadCookie():
|
def prepareLaunchpadCookie():
|
||||||
""" Search for a cookie file in the places as defined by try_globs.
|
""" Search for a cookie file in the places as defined by try_globs.
|
||||||
We shall use this cookie for authentication with Launchpad. """
|
We shall use this cookie for authentication with Launchpad. """
|
||||||
|
2
debian/changelog
vendored
2
debian/changelog
vendored
@ -10,6 +10,8 @@ ubuntu-dev-tools (0.39ubuntu1) intrepid; urgency=low
|
|||||||
- Change the license of all scripts from Kees Cook to the GPL version 3
|
- Change the license of all scripts from Kees Cook to the GPL version 3
|
||||||
or later.
|
or later.
|
||||||
- Order the script names alphabetically in debian/copyright.
|
- Order the script names alphabetically in debian/copyright.
|
||||||
|
* common.py:
|
||||||
|
- Add functions mkdir and readlist.
|
||||||
|
|
||||||
-- Siegfried-Angel Gevatter Pujals <rainct@ubuntu.com> Tue, 12 Aug 2008 20:09:42 +0200
|
-- Siegfried-Angel Gevatter Pujals <rainct@ubuntu.com> Tue, 12 Aug 2008 20:09:42 +0200
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user