-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e355ebc
Showing
5 changed files
with
233 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include template |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#!/usr/bin/env python | ||
from optparse import OptionParser | ||
import shutil | ||
import sys | ||
import os | ||
|
||
""" | ||
Utility to make working with mozconfigs easier | ||
""" | ||
|
||
here = os.path.dirname(os.path.realpath(__file__)) | ||
mozconfigdir = os.getenv('BUILDWITH_HOME') | ||
if mozconfigdir == None or mozconfigdir == '': | ||
mozconfigdir = os.path.expanduser("~/.mozconfigs") | ||
|
||
def mkmozconfig(name): | ||
if not os.path.isdir(mozconfigdir): | ||
os.makedirs(mozconfigdir) | ||
|
||
mozconfig = os.path.join(mozconfigdir, name) | ||
template = os.path.join(mozconfigdir, 'template') | ||
if not os.path.isfile(template): | ||
shutil.copyfile(os.path.join(here, 'template'), template) | ||
shutil.copyfile(template, mozconfig) | ||
|
||
f = open(mozconfig, 'r') | ||
lines = f.readlines() | ||
f.close() | ||
lines[0] = lines[0].rstrip() + name | ||
f = open(mozconfig, 'w') | ||
f.writelines(lines) | ||
f.close() | ||
|
||
def mozconfig(arguments=sys.argv[1:]): | ||
parser = OptionParser(description=__doc__, usage="%prog [options]") | ||
parser.add_option("-l", | ||
dest="ls", | ||
action="store_true", | ||
default=False, | ||
help="lists all available mozconfigs") | ||
parser.add_option('-e', '--edit', | ||
dest="edit", | ||
action="store_true", | ||
default=False, | ||
help="opens the mozconfig for editing"), | ||
opt, args = parser.parse_args(arguments) | ||
|
||
current = os.getenv('MOZCONFIG') | ||
if not opt.ls and not opt.edit: | ||
print current | ||
return | ||
|
||
if opt.ls: | ||
for f in os.listdir(mozconfigdir): | ||
if f != 'template': | ||
if current not in [None, ''] and f == os.path.basename(current): | ||
f += "*" | ||
print f | ||
|
||
if opt.edit: | ||
_edit(current) | ||
|
||
|
||
|
||
def _edit(mozconfig): | ||
editor = os.getenv('EDITOR') | ||
if not editor: | ||
print "Can't open editor, EDITOR environment variable not set" | ||
else: | ||
cmd = editor + ' ' + mozconfig | ||
os.system(cmd) | ||
|
||
|
||
if __name__ == '__main__': | ||
sys.exit(mozconfig()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# -*- mode: shell-script -*- | ||
|
||
function mozconfigwrapper_buildwith_home { | ||
typeset buildwith_home=$BUILDWITH_HOME | ||
if [ "$buildwith_home" = "" ] | ||
then | ||
buildwith_home="$HOME/.mozconfigs" | ||
export BUILDWITH_HOME=$buildwith_home | ||
fi | ||
} | ||
|
||
function buildwith { | ||
mozconfigwrapper_buildwith_home | ||
typeset name="$1" | ||
|
||
if [ ! -f "$BUILDWITH_HOME/$name" ] | ||
then | ||
echo "Error: $BUILDWITH_HOME/$name does not exist" | ||
return 1 | ||
fi | ||
|
||
mozconfig="$BUILDWITH_HOME/$name" | ||
export MOZCONFIG=$mozconfig | ||
echo "$MOZCONFIG" | ||
return 0 | ||
} | ||
|
||
function mkmozconfig { | ||
mozconfigwrapper_buildwith_home | ||
typeset name="$1" | ||
|
||
mozconfig="$BUILDWITH_HOME/$name" | ||
python -c "from mozconfig import mkmozconfig; mkmozconfig('$name')" | ||
echo "Created: $mozconfig" | ||
buildwith $name | ||
} | ||
|
||
function rmmozconfig { | ||
mozconfigwrapper_buildwith_home | ||
typeset name="$1" | ||
|
||
if [ ! -f "$BUILDWITH_HOME/$name" ] | ||
then | ||
echo "Error: $BUILDWITH_HOME/$name does not exist" | ||
return 1 | ||
fi | ||
|
||
mozconfig="$BUILDWITH_HOME/$name" | ||
rm $mozconfig | ||
echo "Removed: $mozconfig" | ||
} | ||
|
||
# Set up tab completion | ||
# Adapted from virtualenvwrapper (written by Doug Hellman and Arthur Koziel) | ||
function mozconfigwrapper_setup_tab_completion { | ||
if [ -n "$BASH" ] ; then | ||
_mozconfigs() { | ||
local cur="${COMP_WORDS[COMP_CWORD]}" | ||
COMPREPLY=( $(compgen -W "`mozconfigwrapper_list_mozconfigs`" -- ${cur}) ) | ||
} | ||
complete -o default -o nospace -F _mozconfigs buildwith rmmozconfig | ||
elif [ -n "$ZSH_VERSION" ] ; then | ||
_virtualenvs () { | ||
reply=( $(mozconfigwrapper_list_mozconfigs) ) | ||
} | ||
compctl -K _virtualenvs buildwith rmmozconfig | ||
fi | ||
} | ||
|
||
# List the available mozconfigs. | ||
function mozconfigwrapper_list_mozconfigs { | ||
# NOTE: DO NOT use ls here because colorized versions spew control characters | ||
# into the output list. | ||
# echo seems a little faster than find, even with -depth 3. | ||
mozconfigwrapper_buildwith_home | ||
(\cd "$BUILDWITH_HOME"; for f in `dir -d *`; do echo $f; done) | ||
} | ||
|
||
mozconfigwrapper_buildwith_home | ||
mozconfigwrapper_setup_tab_completion |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# ***** 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 mozconfigwrapper. | ||
# | ||
# The Initial Developer of the Original Code is | ||
# Mozilla Corporation | ||
# Portions created by the Initial Developer are Copyright (C) 2008 | ||
# the Initial Developer. All Rights Reserved. | ||
# | ||
# Contributor(s): | ||
# Andrew Halberstadt <halbersa@gmail.com> | ||
# | ||
# Alternatively, the contents of this file may be used under the terms of | ||
# either 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 | ||
from setuptools import setup, find_packages | ||
|
||
PACKAGE_NAME = "mozconfigwrapper" | ||
PACKAGE_VERSION = "0.1" | ||
|
||
# take description from README | ||
here = os.path.dirname(os.path.abspath(__file__)) | ||
try: | ||
description = file(os.path.join(here, 'README.md')).read() | ||
except (OSError, IOError): | ||
description = '' | ||
|
||
setup(name=PACKAGE_NAME, | ||
version=PACKAGE_VERSION, | ||
description="Utility to make working with mozconfigs easier", | ||
long_description=description, | ||
author='Andrew Halberstadt', | ||
author_email='halbersa@gmail.com', | ||
url='http://github.com/ahal/mozconfigwrapper', | ||
license='MPL 1.1/GPL 2.0/LGPL 2.1', | ||
py_modules=['mozconfig'], | ||
scripts=['mozconfigwrapper.sh'], | ||
packages=find_packages(exclude=['legacy']), | ||
data_files=[('', ['template'])], | ||
zip_safe=False, | ||
entry_points=""" | ||
[console_scripts] | ||
mozconfig = mozconfig:mozconfig | ||
""", | ||
platforms =['Any'], | ||
classifiers=['Development Status :: 4 - Beta', | ||
'Environment :: Console', | ||
'Intended Audience :: Developers', | ||
'Topic :: Software Development :: Libraries :: Python Modules', | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/ | ||
|
||
ac_add_options --enable-application=browser |