# HG changeset patch # User Jeff Hammel # Date 1273522298 25200 # Node ID 145e111903d248f2a3c252a67c182a5ec7ef8671 # Parent 553f5783999f65aade1f7a7a7ef2fbf70beeb1a6 add MPL license diff -r 553f5783999f -r 145e111903d2 profilemanager/__init__.py --- a/profilemanager/__init__.py Fri May 07 17:50:10 2010 -0700 +++ b/profilemanager/__init__.py Mon May 10 13:11:38 2010 -0700 @@ -1,2 +1,38 @@ +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is mozilla.org code. +# +# The Initial Developer of the Original Code is +# Mozilla.org. +# Portions created by the Initial Developer are Copyright (C) 2010 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# Jeff Hammel (Original author) +# +# Alternatively, the contents of this file may be used under the terms of +# either of the GNU General Public License Version 2 or later (the "GPL"), +# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** # from manager import ProfileManager diff -r 553f5783999f -r 145e111903d2 profilemanager/command.py --- a/profilemanager/command.py Fri May 07 17:50:10 2010 -0700 +++ b/profilemanager/command.py Mon May 10 13:11:38 2010 -0700 @@ -1,3 +1,39 @@ +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is mozilla.org code. +# +# The Initial Developer of the Original Code is +# Mozilla.org. +# Portions created by the Initial Developer are Copyright (C) 2010 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# Jeff Hammel (Original author) +# +# Alternatively, the contents of this file may be used under the terms of +# either of the GNU General Public License Version 2 or later (the "GPL"), +# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** """ a command-line interface to the command line, a la pythonpaste """ @@ -9,7 +45,7 @@ if 'commands' not in globals(): commands = {} - + def command(function): # XXX should get bound/unbound state from function (how?) global commands @@ -24,7 +60,7 @@ args = argspec.args[1:] optional = None commands[name] = { 'doc': doc, - 'args': args, + 'args': args, 'optional': optional, 'varargs': argspec.varargs } @@ -90,7 +126,7 @@ default=False, help=help) else: parser.add_option('--%s' % key, help=help) - + return parser class CommandParser(OptionParser): @@ -117,7 +153,7 @@ def parse(self, args=sys.argv[1:]): """global parse step""" - + self.options, args = self.parse_args(args) # help/sanity check -- should probably be separated diff -r 553f5783999f -r 145e111903d2 profilemanager/main.py --- a/profilemanager/main.py Fri May 07 17:50:10 2010 -0700 +++ b/profilemanager/main.py Mon May 10 13:11:38 2010 -0700 @@ -1,5 +1,42 @@ #!/usr/bin/env python +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is mozilla.org code. +# +# The Initial Developer of the Original Code is +# Mozilla.org. +# Portions created by the Initial Developer are Copyright (C) 2010 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# Jeff Hammel (Original author) +# +# Alternatively, the contents of this file may be used under the terms of +# either of the GNU General Public License Version 2 or later (the "GPL"), +# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** + import os import sys diff -r 553f5783999f -r 145e111903d2 profilemanager/manager.py --- a/profilemanager/manager.py Fri May 07 17:50:10 2010 -0700 +++ b/profilemanager/manager.py Mon May 10 13:11:38 2010 -0700 @@ -1,3 +1,39 @@ +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is mozilla.org code. +# +# The Initial Developer of the Original Code is +# Mozilla.org. +# Portions created by the Initial Developer are Copyright (C) 2010 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# Jeff Hammel (Original author) +# +# Alternatively, the contents of this file may be used under the terms of +# either of the GNU General Public License Version 2 or later (the "GPL"), +# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** """ manage Mozilla/Firefox profiles """ @@ -72,7 +108,7 @@ # update profiles.ini self.add(name, relative and dirname or path, relative) - + # return the directory name return path @@ -107,7 +143,7 @@ """ # filesystem path of the `from` profile - source_path = self.path(source) + source_path = self.path(source) # dest: fs path to back up to relative = False @@ -163,7 +199,7 @@ # copy the files self.clone(profile, dest, add=False) - + # add backup entry to profiles.ini (colon separated): # `Backup=$(profile)s.$(datestamp)s.bak` if parser.has_option(section, 'Backups'): @@ -243,7 +279,7 @@ seconds_snice_epoch = None try: seconds_since_epoch = int(date) - + except ValueError: pass if seconds_since_epoch and seconds_since_epoch > time.localtime().tm_year: @@ -254,7 +290,7 @@ if isinstance(date, datetime): # convert to s since epoch date = time.mktime(date.timetuple()) - + for backup in backups: if backup[1] < date: break @@ -288,7 +324,7 @@ # delete the directory shutil.rmtree(backup_path) - + # delete the entry from ``profiles.ini`` parser = self.parser() section = self.section(profile) @@ -328,7 +364,7 @@ assert profile not in self.profiles_dict(), 'Profile "%s" already in %s' % (name, self.profiles) parser = self.parser() - # find and add the section + # find and add the section ctr = 0 section = 'Profile%d' % ctr # unsure of this naming convention while section in parser.sections(): diff -r 553f5783999f -r 145e111903d2 profilemanager/tests/test.py --- a/profilemanager/tests/test.py Fri May 07 17:50:10 2010 -0700 +++ b/profilemanager/tests/test.py Mon May 10 13:11:38 2010 -0700 @@ -1,5 +1,42 @@ #!/usr/bin/env python +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is mozilla.org code. +# +# The Initial Developer of the Original Code is +# Mozilla.org. +# Portions created by the Initial Developer are Copyright (C) 2010 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# Jeff Hammel (Original author) +# +# Alternatively, the contents of this file may be used under the terms of +# either of the GNU General Public License Version 2 or later (the "GPL"), +# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** + import os import time from profilemanager import ProfileManager @@ -22,7 +59,7 @@ manager.remove(profile) assert os.listdir(profiles_dir) == ['profiles.ini'], 'profiles_dir isnt empty except profiles.ini' assert file(profiles).read().strip() == '[General]', 'profiles.ini isnt nearly empty' - + # Create a new profile: profiledir = manager.new('testprofile') assert profiledir.endswith('.testprofile'), 'profiledir should end with testprofile, instead it is %s' % profiledir @@ -63,7 +100,7 @@ assert restored != old_backups[0], "Tried to restore the newest but got the old one [%s]" % old_backups[0] manager.restore('testprofile', delete=True) manager.restore('testprofile', delete=True) -assert not manager.backups() +assert not manager.backups() assert manager.list() == ['testprofile'] # Cleanup: diff -r 553f5783999f -r 145e111903d2 profilemanager/utils.py --- a/profilemanager/utils.py Fri May 07 17:50:10 2010 -0700 +++ b/profilemanager/utils.py Mon May 10 13:11:38 2010 -0700 @@ -1,5 +1,42 @@ #!/usr/bin/env python +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is mozilla.org code. +# +# The Initial Developer of the Original Code is +# Mozilla.org. +# Portions created by the Initial Developer are Copyright (C) 2010 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# Jeff Hammel (Original author) +# +# Alternatively, the contents of this file may be used under the terms of +# either of the GNU General Public License Version 2 or later (the "GPL"), +# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** + def format_tabular(table, spacer=' '): columns = [0 for i in range(max([len(row) for row in table]))] assert (len(columns) == min([len(row) for row in table])) @@ -16,7 +53,7 @@ values.append(' ' * (columns[index] - len(column))) retval.append(format_string % tuple(values)) return '\n'.join(retval) - + if __name__ == '__main__': test_data = [ ['fox', 'i am a fox!', 'Foxkeh'], ['cat', 'meow', 'Lilly'], diff -r 553f5783999f -r 145e111903d2 setup.py --- a/setup.py Fri May 07 17:50:10 2010 -0700 +++ b/setup.py Mon May 10 13:11:38 2010 -0700 @@ -1,3 +1,39 @@ +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is mozilla.org code. +# +# The Initial Developer of the Original Code is +# Mozilla.org. +# Portions created by the Initial Developer are Copyright (C) 2010 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# Jeff Hammel (Original author) +# +# Alternatively, the contents of this file may be used under the terms of +# either of the GNU General Public License Version 2 or later (the "GPL"), +# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** from setuptools import setup, find_packages import sys, os