├── .gitignore
├── requirements.txt
├── setup.cfg
├── docs
├── screenshot1.png
├── screenshot2.png
├── modelLayer.md
└── useCases.md
├── test
├── sample_cherfile
├── __init__.py
└── test.py
├── MANIFEST
├── gitcher
├── __init__.py
├── not_found_prof_error.py
├── completer.py
├── dictionary.py
├── prof.py
├── model_layer.py
└── __main__.py
├── INSTALL.md
├── setup.py
├── manpages
└── gitcher.1
├── README.md
├── CONTRIBUTING.md
├── CHANGELOG.md
└── LICENSE
/.gitignore:
--------------------------------------------------------------------------------
1 | .python-version
2 |
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | prettytable==0.7.2
2 | validate-email==1.3
3 |
--------------------------------------------------------------------------------
/setup.cfg:
--------------------------------------------------------------------------------
1 | [metadata]
2 | description-file = README.md
3 | license-file = LICENSE
4 |
--------------------------------------------------------------------------------
/docs/screenshot1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bglezseoane/gitcher/HEAD/docs/screenshot1.png
--------------------------------------------------------------------------------
/docs/screenshot2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bglezseoane/gitcher/HEAD/docs/screenshot2.png
--------------------------------------------------------------------------------
/test/sample_cherfile:
--------------------------------------------------------------------------------
1 | # CHERFILE SAMPLE
2 |
3 | home,Jane Doe,janedoe@home,BBBB5678,False
4 | work,Jane Doe,janedoe@work,AAAA1234,True
5 | work not sign,Jane Doe,janedoe@work,None,False
6 |
--------------------------------------------------------------------------------
/MANIFEST:
--------------------------------------------------------------------------------
1 | # file GENERATED by distutils, do NOT edit
2 | LICENSE
3 | setup.cfg
4 | setup.py
5 | gitcher/__main__.py
6 | gitcher/completer.py
7 | gitcher/dictionary.py
8 | gitcher/model_layer.py
9 | gitcher/not_found_prof_error.py
10 | gitcher/prof.py
11 | manpages/gitcher.1
12 |
--------------------------------------------------------------------------------
/gitcher/__init__.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | ###########################################################
4 | # Gitcher 3.2
5 | #
6 | # The git profile switcher
7 | #
8 | # Copyright 2019-2020 Borja González Seoane
9 | #
10 | # Contact: garaje@glezseoane.es
11 | ###########################################################
12 |
13 | __author__ = 'Borja González Seoane'
14 | __copyright__ = 'Copyright 2019, Borja González Seoane'
15 | __credits__ = 'Borja González Seoane'
16 | __license__ = 'LICENSE'
17 | __version__ = '3.2'
18 | __maintainer__ = 'Borja González Seoane'
19 | __email__ = 'garaje@glezseoane.es'
20 | __status__ = 'Production'
21 |
--------------------------------------------------------------------------------
/gitcher/not_found_prof_error.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | ###########################################################
4 | # Gitcher 3.2
5 | #
6 | # The git profile switcher
7 | #
8 | # Copyright 2019-2020 Borja González Seoane
9 | #
10 | # Contact: garaje@glezseoane.es
11 | ###########################################################
12 |
13 | """Gitcher's 'not_found_prof_error' class module
14 |
15 | This module constains the class taht represents a gitcher not found profile
16 | exception.
17 | """
18 |
19 |
20 | class NotFoundProfError(Exception):
21 | """Class that represents a gitcher not found profile exception."""
22 | pass
23 |
--------------------------------------------------------------------------------
/test/__init__.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | ###########################################################
4 | # Gitcher 3.2 (Test suite)
5 | #
6 | # The git profile switcher
7 | #
8 | # Copyright 2019-2020 Borja González Seoane
9 | #
10 | # Contact: garaje@glezseoane.es
11 | ###########################################################
12 |
13 | __author__ = 'Borja González Seoane'
14 | __copyright__ = 'Copyright 2019, Borja González Seoane'
15 | __credits__ = 'Borja González Seoane'
16 | __license__ = 'LICENSE'
17 | __version__ = '3.2'
18 | __maintainer__ = 'Borja González Seoane'
19 | __email__ = 'garaje@glezseoane.es'
20 | __status__ = 'Production'
21 |
--------------------------------------------------------------------------------
/docs/modelLayer.md:
--------------------------------------------------------------------------------
1 | # gitcher model layer
2 |
3 | The Gitcher profiles will be saved into a $HOME's dotfile named `.cherfile`.
4 |
5 | Using the Gitcher options it's easier to add new profiles and it's the recommended method to do. Manually modifying the file has the disappointment that it is possible to add the new profiles incorrectly due to typing errors.
6 |
7 |
8 | ## Format
9 |
10 | File data rows are composed by:
11 |
12 | `profName, name, email, signKey, signPref`
13 |
14 | The `profName` parameter acts like primary key of the dataset and have to be unique. Comma (`,`) acts as separator, so quotation marks are not needed to enclose parameters of more than one word.
15 |
16 | Lines started with `#` will be ignored, so are perfect to use like comments.
17 |
18 |
--------------------------------------------------------------------------------
/INSTALL.md:
--------------------------------------------------------------------------------
1 | # Installation guide
2 |
3 | This software is available for Unix-like systems (Linux and MacOS).
4 |
5 | ## Homebrew (recommended for MacOS)
6 |
7 | You can use Homebrew to install this program via my tap repository:
8 |
9 | ```sh
10 | brew install bglezseoane/tap/gitcher
11 | ```
12 |
13 | ## Pip (recommended for Linux)
14 |
15 | You also can use PYPI to install this program:
16 |
17 | ```sh
18 | pip install gitcher
19 | ```
20 |
21 | ## Manual
22 |
23 | Alternative, clone and go to this repository home directory, and then run:
24 |
25 | ```sh
26 | python setup.py install
27 | ```
28 |
29 | ## Additional notes
30 |
31 | All methods install last Gitcher stable version on your machine. Now you can run it on your shell using:
32 |
33 | ```sh
34 | gitcher
35 | ```
36 |
37 |
38 |
39 | Read the man of this tool to known more about its use.
40 |
41 | **Note about man pages**: if you use `pip` method to install this program, assert that man directories of your Python environment are added to your `MANPATH` to can get this program's man pages with the `man` command. Python might install man pages in default machine level directories.
42 |
--------------------------------------------------------------------------------
/gitcher/completer.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | ###########################################################
4 | # Gitcher 3.2
5 | #
6 | # The git profile switcher
7 | #
8 | # Copyright 2019-2020 Borja González Seoane
9 | #
10 | # Contact: garaje@glezseoane.es
11 | ###########################################################
12 |
13 | """Gitcher's completer class module.
14 |
15 | This module presents the class that represents a gitcher completer for user
16 | inputs.
17 | """
18 |
19 | import readline
20 |
21 |
22 | class TabCompleter(object):
23 | """Class that represents a gitcher tab user input completer."""
24 |
25 | def __completer(self, input: str, state: int) -> str:
26 | """This function provides an autocompletion service for the user
27 | inputs.
28 |
29 | :param input: User input try
30 | :type input: str
31 | :param state: User input prediction selector
32 | :type state: int
33 | :return: User reply after canalize question via 'input()' function.
34 | :rtype: str
35 | """
36 | line = readline.get_line_buffer()
37 |
38 | if not line:
39 | return [pat + " " for pat in self.pattern_list][state]
40 |
41 | else:
42 | return [pat + " " for pat in self.pattern_list
43 | if pat.startswith(line)][state]
44 |
45 | def __init__(self, pattern_list: [str]):
46 | self.pattern_list = pattern_list
47 | self.service = self.__completer
48 |
--------------------------------------------------------------------------------
/docs/useCases.md:
--------------------------------------------------------------------------------
1 | # gitcher use cases
2 |
3 | A git switcher. It facilitates the switching between git profiles,importing configuration settings such as name, email and user signatures.
4 |
5 |
6 | ## Use cases of Gitcher
7 |
8 | - [L]: List the preset profiles.
9 | - [O]: See currently active (ON) profile.
10 | - [S]: Set into an existing repository a configuration profile.
11 | - [G]: Set global a configuration profile.
12 | - [A]: Add a new profile.
13 | - [M]: Mirror profile (create a copy of a profile with a different name).
14 | - [D]: Delete a profile.
15 | - [U]: Update a profile.
16 | - [C]: Create cherfile.
17 |
18 |
19 | ## Interactive mode
20 |
21 | Use `gitcher` command to open the interactive console. Once this is done,
22 | Gitcher automatically assert cherfile is reachable. If not, create it [C]. Then automatically list your preset profiles [[L], [O]]. Next
23 | ask you for orders:
24 |
25 | - `s` to set a profile to current directory repository [S].
26 | - `g` to set a profile as global git profile [G].
27 | - `a` to add a new profile [A].
28 | - `u` to update a profile [U].
29 | - `m` to mirror a profile [M].
30 | - `d` to delete a profile [D].
31 | - `Ctrl.+C` to quit *gitcher*.
32 |
33 |
34 | ## Fast mode shortcuts
35 |
36 | Elementary options are available via command line to allow Gitcher to be
37 | scriptable and integrable on POSIX systems. To use:
38 |
39 | - `gitcher -l`: [L]'s shortcut.
40 | - `gitcher -o`: [O]'s shortcut.
41 | - `gitcher -s `: [S]'s shortcut.
42 | - `gitcher -g `: [G]'s shortcut.
43 | - `gitcher -a <'True' or
44 | 'False' as signpref>`:
45 | [A]'s shortcut.
46 | - `gitcher -d `: [D]'s shortcut.
47 |
--------------------------------------------------------------------------------
/setup.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | ###########################################################
4 | # Gitcher 3.2 (Setup file)
5 | #
6 | # The git profile switcher
7 | #
8 | # Copyright 2019-2020 Borja González Seoane
9 | #
10 | # Contact: garaje@glezseoane.es
11 | ###########################################################
12 |
13 | from setuptools import setup
14 |
15 |
16 | setup(
17 | name='gitcher',
18 | version='3.2',
19 | packages=['gitcher'],
20 | entry_points={
21 | 'console_scripts': [
22 | 'gitcher=gitcher.__main__:main',
23 | ],
24 | },
25 | python_requires='>=3.6',
26 | install_requires=['validate_email==1.3', 'prettytable==0.7.2'],
27 | data_files=[('share/man/man1', ['manpages/gitcher.1']),
28 | ("", ["LICENSE"])],
29 | url='https://github.com/bglezseoane/gitcher',
30 | download_url='https://github.com/bglezseoane/gitcher/archive/v3.2.tar.gz',
31 | license='LICENSE',
32 | author='Borja González Seoane',
33 | author_email='garaje@glezseoane.es',
34 | description='The git profile switcher.',
35 | long_description='The git profile switcher. It facilitates the switching '
36 | 'between git profiles, importing configuration settings '
37 | 'such as name, email and user signatures.',
38 | classifiers=[
39 | 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
40 | 'Intended Audience :: Developers',
41 | 'Development Status :: 5 - Production/Stable',
42 | 'Programming Language :: Python',
43 | 'Programming Language :: Python :: 3',
44 | 'Operating System :: Unix',
45 | 'Operating System :: POSIX',
46 | 'Operating System :: MacOS',
47 | 'Operating System :: POSIX :: Linux',
48 | 'Topic :: Utilities',
49 | 'Topic :: Software Development',
50 | 'Topic :: Software Development :: Version Control',
51 | 'Topic :: Software Development :: Version Control :: Git'
52 | ],
53 | )
54 |
--------------------------------------------------------------------------------
/manpages/gitcher.1:
--------------------------------------------------------------------------------
1 | .\" Manpage for gitcher.
2 | .\" Contact garaje@glezseoane.es to any requirement.
3 | .TH man 1 "18 Apr 2019" "3.2" "gitcher man page"
4 | .SH NAME
5 | gitcher \- the git profile switcher
6 | .SH SYNOPSIS
7 | \fBgitcher\fR [\fB-l\fR|\fB-o\fR|\fB-s\fR|\fB-g\fR|\fB-a\fR|\fB-d\fR ...]
8 | .SH DESCRIPTION
9 | \fBgitcher\fR is a git profile switcher. It facilitates the switching between git profiles, importing configuration settings such as name, email and user signatures.
10 | .SH OPTIONS
11 | .IP "\fINONE\fR"
12 | Opens the interactive mode. It is possible to access to all the operations with this mode, that offers you inline help.
13 | .IP "\fB\-l\fR"
14 | Shows a list with all the \fBgitcher\fR saved profiles.
15 | .IP "\fB\-o\fR"
16 | Displays the activated (ON) gitcher profile for the current working directory.
17 | .IP "\fB\-s\fR \fIprofname\fR"
18 | Set into the existing repository of the current working directory the selected profile.
19 | .IP "\fB\-g\fR \fIprofname\fR"
20 | Set globally the selected gitcher profile.
21 | .IP "\fB\-a\fR \fIprofname\fR \fIname\fR \fIemail\fR \fIsignkey\fR|\fINone\fR \fITrue\fR|\fIFalse\fR
22 | Add a new profile. Inputs are profile name, git user name, git user email, PGP sign key or None (depending if you want to use one), and True or False (depending if you want to use your PGP key to autosign every commit).
23 | .IP "\fB\-d\fR \fIprofname\fR"
24 | Delete the selected profile.
25 | .SH PGP KEYS
26 | \fBgitcher\fR only needs your key ID (the last eight digits of your validation fingerprint) to work. This is the information that you have to provide to \fBgitcher\fR while the creation of your profile.
27 | .SH SAVED DATA
28 | \fBgitcher\fR works with a dotfile saved on user $HOME directory. It is named \fI~/.cherfile\fR and it is not recommended to edit it manually.
29 | .SH EXIT STATUS
30 | Exits 0 on success and 1 on error.
31 | .SH SEE ALSO
32 | \fBgit\fR(1).
33 | .SH BUGS
34 | No known bugs.
35 | .SH AUTHOR
36 | Borja Gonzalez Seoane is the author of \fBgitcher\fR.
37 | .SH ACKNOWLEDGMENTS
38 | Santiago Fernandez Gonzalez for an effusive reception of the tool, being the highest tester of \fBgitcher\fR after its own author.
39 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Gitcher
2 |
3 | *The git profile switcher*
4 |
5 | 
6 |
7 | - Webpage: http://www.borja.glezseoane.es/garaje/gitcher.html.
8 | - Mailing list board: http://listas.glezseoane.es/mailman/listinfo/gitcher_listas.glezseoane.es.
9 |
10 | Gitcher is the git profile switcher, a TUI (terminal user interface) application which facilitates the switching between git profiles, importing configuration settings such as name, email and user signatures.
11 |
12 | 
13 |
14 | 
15 |
16 |
17 | ## Purpose
18 |
19 | It is possible that you have multiple git configurations. E.g.:
20 |
21 | - Work profile
22 |
23 | ```
24 | Name: Jane Doe
25 | Email: janedoe@work
26 | PGP Key: AAAA1234
27 | ```
28 |
29 | - Personal profile
30 |
31 | ```
32 | Name: Jane Doe
33 | Email: janedoe@home
34 | PGP Key: BBBB5678
35 | ```
36 |
37 | It could be a nuisance to switch between profiles while working on different projects. In addition, it is common to forget what profile you are using when you start commit in a new repository, and rewrite your story can be a bigger nuisance.
38 |
39 | This tool aims to facilitate the configuration of the profile to be used in each project, an agile exchange between the different profiles and a way to control the profiles that you are using in your machine.
40 |
41 |
42 | ## What is a Gitcher profile?
43 |
44 | A profile is a git configuration data set that includes:
45 |
46 | - Name.
47 | - Email.
48 | - PGP Key (optional).
49 | - GPG autosigning preference (activate it do that every commit will be signed).
50 |
51 | It is identified by a subject tittle like "work" or "university" that have to be unique.
52 |
53 |
54 | ## Saved data
55 |
56 | The `~/.cherfile` file contains the saved profiles data.
57 |
58 |
59 | ## To set up
60 |
61 | Please, read the [install guide](./INSTALL.md).
62 |
63 |
64 | ## Acknowledgments
65 |
66 | - [Santiago Fernández González](https://github.com/santiagofdezg), for an effusive reception of the tool, being the highest tester of Gitcher after its own author.
67 | - [Arda Kosar](https://github.com/abkosar), for his work on issue [#3](https://github.com/glezseoane/gitcher/issues/3).
68 | - [Mat Kelly](https://github.com/machawk1), for his work with documentation misprints.
69 |
--------------------------------------------------------------------------------
/gitcher/dictionary.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | ###########################################################
4 | # Gitcher 3.2
5 | #
6 | # The git profile switcher
7 | #
8 | # Copyright 2019-2020 Borja González Seoane
9 | #
10 | # Contact: garaje@glezseoane.es
11 | ###########################################################
12 |
13 | """Gitcher's dictionary class module.
14 |
15 | This module contains the class that represents the gitcher dictionary
16 | container class.
17 | """
18 |
19 | from gitcher import model_layer
20 |
21 |
22 | class Dictionary(object):
23 | """This class presents the gitcher dictionary container, with all the
24 | options keys and also with a collection of the user data obtained with
25 | the start of the program execution."""
26 |
27 | # noinspection PyShadowingNames
28 | def __init__(self):
29 | self.cmds_interactive_mode = ['s', 'g', 'a', 'd', 'u', 'm', 'q']
30 | self.cmds_fast_mode = ['l', 's', 'g', 'a', 'd', 'o']
31 |
32 | profs = model_layer.recuperate_profs()
33 | self.profs_profnames = [prof.profname for prof in profs]
34 | self.profs_names = [prof.name for prof in profs]
35 | self.profs_emails = [prof.email for prof in profs]
36 | # Next force string cast because signkey could be None
37 | self.profs_signkeys = [str(prof.signkey) for prof in profs]
38 |
39 | def get_union_all(self) -> [str]:
40 | """This function returns a list with the union of all the dictionary
41 | subsets."""
42 | return self.cmds_interactive_mode + self.cmds_fast_mode + \
43 | self.profs_profnames + self.profs_names + self.profs_signkeys
44 |
45 | def get_union_cmds_set(self) -> [str]:
46 | """This function returns a list with the union of all the dictionary
47 | subsets relatives to the gitcher operative context."""
48 | return self.cmds_interactive_mode + self.cmds_fast_mode
49 |
50 | def get_intersection_cmds_set(self) -> [str]:
51 | """This function returns a list with the intersection of the
52 | dictionary subsets relatives to the program fast mode and the
53 | program interactive mode."""
54 | return [set(self.cmds_interactive_mode) & set(self.cmds_fast_mode)]
55 |
56 | def get_union_git_set(self) -> [str]:
57 | """This function returns a list with the union of all the dictionary
58 | subsets relatives to the git context (i.e.: git profile names,
59 | user names, emails and signing keys)."""
60 | return self.profs_profnames + self.profs_names +\
61 | self.profs_emails + self.profs_signkeys
62 |
--------------------------------------------------------------------------------
/gitcher/prof.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | ###########################################################
4 | # Gitcher 3.2
5 | #
6 | # The git profile switcher
7 | #
8 | # Copyright 2019-2020 Borja González Seoane
9 | #
10 | # Contact: garaje@glezseoane.es
11 | ###########################################################
12 |
13 | """Gitcher's profile class module
14 |
15 | This module constains the class that represents a gitcher profile instance.
16 | """
17 |
18 |
19 | class Prof(object):
20 | """Class that represents a gitcher profile."""
21 |
22 | def __init__(self, profname: str, name: str, email: str,
23 | signkey: str = None, signpref: bool = False):
24 | self.profname = profname
25 | self.name = name
26 | self.email = email
27 | self.signkey = signkey
28 | self.signpref = signpref
29 |
30 | def __str__(self):
31 | if self.signkey is not None:
32 | signkey_str = self.signkey
33 | if self.signpref:
34 | signpref_str = "Enabled"
35 | else:
36 | signpref_str = "Disabled"
37 | else:
38 | signkey_str = "Sign disabled"
39 | signpref_str = "Autosign disabled"
40 |
41 | return self.profname + ": " + ", ".join([self.name, self.email,
42 | signkey_str, signpref_str])
43 |
44 | def simple_str(self):
45 | """This function return a minimalistic representation of the profile,
46 | without its name. It is util to some high level functions.
47 | """
48 | if self.signkey is not None:
49 | signkey_str = self.signkey
50 | if self.signpref:
51 | signpref_str = "autosign enabled"
52 | else:
53 | signpref_str = "autosign disabled"
54 | else:
55 | signkey_str = "sign disabled"
56 | signpref_str = "autosign disabled"
57 |
58 | return ", ".join([self.name, self.email, signkey_str, signpref_str])
59 |
60 | def tpl(self):
61 | """This function return a tuple representation of the object."""
62 | if self.signkey is not None:
63 | signkey_str = self.signkey
64 | if self.signpref:
65 | signpref_str = "Enabled"
66 | else:
67 | signpref_str = "Disabled"
68 | else:
69 | signkey_str = "Disabled"
70 | signpref_str = ""
71 |
72 | return self.profname, self.name, self.email, signkey_str, signpref_str
73 |
74 | def __hash__(self):
75 | return hash((self.name + self.email + str(self.signkey) +
76 | str(self.signpref)))
77 |
78 | def __eq__(self, other):
79 | return hash(self) == hash(other)
80 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing guide
2 |
3 | Following these guidelines helps to communicate that you respect the time of the developers managing and developing this open source project. In return, they should reciprocate that respect in addressing your issue, assessing changes, and helping you finalize your pull requests.
4 |
5 | Please, write to González Seoane ([garaje@glezseoane.es](mailto:garaje@glezseoane.es)) for any additional questions or suggestions.
6 |
7 | ## Mailing lists
8 |
9 | Suscribe the mailing list to be updated about the news of Gitcher and to discuss about its development.
10 |
11 | Mailing list board: http://listas.glezseoane.es/mailman/listinfo/gitcher_listas.glezseoane.es.
12 |
13 |
14 |
15 | ## Suggesting new features
16 |
17 | If you find yourself wishing for a feature that doesn't exist in Gitcher, open an issue on our GitHub issues tracker which describes the feature you would like to see, why you need it, and how it should work. Use the `enhancement` label in your issue.
18 |
19 |
20 |
21 | ## Bug reports
22 |
23 | Open an issue on our GitHub issues list which describes the bug thoroughly. Use the `bug` label in your issue.
24 |
25 |
26 |
27 | ## Style guides and conventions
28 |
29 | ### Code style guide
30 |
31 | Gitcher is written in Python, so the PEP-8 rules will be followed to the code standardization. It is highly recommended to use an IDE that revise PEP-8 conventions in your code, as, for example JetBrains's PyCharm.
32 |
33 | **Pull request or other type of contributions that not respect PEP-8's conventions could be discarded. The code standardization is a very important part of a good managed software project.**
34 |
35 | You can take a look of PEP-8 in the article *[PEP-8: Style Guide for Python Code](https://www.python.org/dev/peps/pep-0008/)*.
36 |
37 | If you don't want to read PEP-8, please observe yet implement code and try to emulate the presentation.
38 |
39 |
40 | ### Git commit messages
41 |
42 | - Use the present tense ("Add feature" not "Added feature").
43 | - Use the imperative mood ("Move cursor to..." not "Moves cursor to...").
44 | - Use the first line as subject line.
45 | - Consider starting the commit message with an applicable tag attending its normal form:
46 | - `docs:`: documentation.
47 | - `feat:`: new features.
48 | - `fix`: fixes of present features.
49 | - `style`: code cleanliness.
50 | - Limit the first line to 50 characters or less. Start with capital letter and do not close with a dot.
51 | - Add a white line after the subject line.
52 | - Limit all the lines but first to 72 characters or less.
53 | - Reference issues and pull requests liberally after the first line.
54 |
55 |
56 | ### Git branching
57 |
58 | This repository follows the [Vincent Driessen's successful Git branching model](https://nvie.com/posts/a-successful-git-branching-model/).
59 |
60 | The `master` branch is reserved to merges of releases and some documentation changes. The releases are identified with a tag.
61 |
62 | Other things will be done in `develop` branch, which can contain other feat-specific branches, if necessary. The release-itself stuff will be done in an `rel-` specific branch, then merged in `master` and `develop`.
63 |
64 | It is recommended to use `git-workflow` to facilitate the processes. This tools was developed by Vincent Driessen, the author of our Git branching model, so they fit perfectly.
65 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Change log
2 |
3 | All notable changes to this project will be documented in this file.
4 |
5 | ## v3.2 of 2019-04-18
6 |
7 | This version adds document improvements, mailing list and homepage notices and fix some installation issues.
8 |
9 | Note: This version has had a pair of prereleases (v3.1.2 and v3.1.3), but due to errors with the PYPI packaging they have been removed.
10 |
11 |
12 |
13 | ## v3.1.1 of 2019-10-19
14 |
15 | This version provides the same software, but removes the repository's GitLab mirror.
16 |
17 |
18 |
19 | ## v3.1 of 2019-10-05
20 |
21 | #### Changed
22 |
23 | - Improve data TUI presentation.
24 | - Correct the PGP acronym use.
25 |
26 |
27 |
28 | ## v3.0 of 2019-09-27
29 |
30 | #### Added
31 |
32 | - Contribution guide.
33 |
34 |
35 | #### Changed
36 |
37 | - Solve some bugs.
38 | - Improve data TUI presentation.
39 |
40 |
41 |
42 | ## v2.2 of 2019-07-01
43 |
44 | #### Added
45 |
46 | - Test suite.
47 |
48 |
49 | #### Changed
50 |
51 | - Mirroring configuration. Set GitHub copy as main.
52 |
53 |
54 |
55 | ## v2.1 of 2019-06-18
56 |
57 | #### Changed
58 |
59 | - This version solves some performance bugs.
60 |
61 |
62 |
63 | ## v2.0 of 2019-04-28
64 |
65 | This is the first version available to download via Homebrew.
66 |
67 | #### Added
68 |
69 | - Automatic setup of script endpoint to run the module directly using `$ gitcher` command.
70 | - Interactive mode loop closure.
71 | - Fast mode profiles listing operation.
72 |
73 |
74 |
75 | ## v1.3 of 2019-04-16
76 |
77 | #### Added
78 |
79 | - Profiles list representation switch.
80 |
81 |
82 |
83 | ## v1.2.2 of 2019-03-06
84 |
85 | #### Changed
86 |
87 | - Fix small fails with PyPI distribution.
88 |
89 |
90 | ## v1.2 of 2019-03-06
91 |
92 | This is the first version available on PyPI.
93 |
94 |
95 |
96 | ## v1.0 of 2019-03-06
97 |
98 | This is the first stable version of the program. It is fully tested.
99 |
100 | #### Added
101 |
102 | - Autocompleter helper support (only for interactive mode).
103 |
104 |
105 | #### Changed
106 |
107 | - Now a dictionary module recopilates every program keys.
108 | - Escape mode: Ctrl.+C is the new method to escape. Command words like 'quit' or 'exit' will not be supported from this version.
109 | - Relevant performance fixes and user experience improvements.
110 |
111 |
112 |
113 | ## v0.4b0 of 2019-02-23
114 |
115 | #### Added
116 |
117 | - Update use case option.
118 | - Mirror use case option.
119 | - Fast mode get current active profile option.
120 | - Sort profiles list display.
121 |
122 |
123 | #### Changed
124 |
125 | - Escape command: 'q' by 'quit'. 'q' may be interesting like name or profile
126 | param.
127 | - Securize and better isolate option validation.
128 | - Relevant performance fixes.
129 |
130 |
131 |
132 | ## v0.3b0 of 2019-02-19
133 |
134 | #### Added
135 |
136 | - Fast mode: use shortcuts to run directly gitcher orders.
137 | - Current git profile status.
138 | - User input validation.
139 | - Cherfile comments support.
140 |
141 |
142 | #### Changed
143 |
144 | - Securize and better isolate model layer operative.
145 | - Fix some performance failures.
146 |
147 |
148 |
149 |
150 | ## Previous alpha phase
151 |
152 | ### v0.2a1 of 2019-02-09
153 |
154 | #### Changed
155 |
156 | This version fixes an error with the set up routine. The necessary libraries were not being imported.
157 |
158 |
159 |
160 | ### v0.2a0 of 2019-02-09
161 |
162 | #### Added
163 |
164 | - Installs the program manpages during the set up routine.
165 |
166 |
167 | #### Changed
168 |
169 | - Improves the software design of the project. Refactors the project as Python package and isolates GITCHER file access to a model layer.
170 | - Improves the user experience with better output printing presentation.
171 |
172 |
173 |
174 | ### v0.1a1 of 2019-02-07
175 |
176 | #### Changed
177 |
178 | Set global option crashed when try to use from a directory that does not contains a git repository. It was by a performance dependencies of 'gitpython' library. The library will be removed from imports and the git commands will be played with operating system calls instead.
179 |
180 |
181 |
182 | ### v0.1a0 of 2019-02-05
183 |
184 | #### Added
185 |
186 | First alpha release. This version is a first approximation of the tool. It covers the entire initial scope of functionalities proposed.
187 |
--------------------------------------------------------------------------------
/test/test.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | ###########################################################
4 | # Gitcher 3.2 (Test suite)
5 | #
6 | # The git profile switcher
7 | #
8 | # Copyright 2019-2020 Borja González Seoane
9 | #
10 | # Contact: garaje@glezseoane.es
11 | ###########################################################
12 |
13 | """Gitcher's test suite."""
14 |
15 | import os
16 | import shutil
17 | import tempfile
18 | import unittest
19 | import warnings
20 | from unittest import TestCase, mock
21 |
22 | import git
23 |
24 | import gitcher.__main__ as gitcher
25 | import gitcher.model_layer as model_layer
26 | import gitcher.prof as prof
27 |
28 |
29 | # noinspection DuplicatedCode
30 | class UnitTestSuite(TestCase):
31 | """Unit test suite.
32 |
33 | Checks the model operative from the most superficial layer available.
34 | """
35 |
36 | def test_set_prof(self):
37 | """Simulates the set order to check the correct operative effect."""
38 | warnings.simplefilter("ignore",
39 | ResourceWarning) # Working with tmp files
40 |
41 | # Uses a mock tmp cherfile
42 | tmp_dir = tempfile.mkdtemp()
43 | cherfile_path = tempfile.mkstemp(dir=tmp_dir, prefix='tmp_cherfile')
44 | mock.patch('model_layer.CHERFILE', cherfile_path)
45 | model_layer.create_cherfile()
46 |
47 | # Commiter data to create the mock repo
48 | commiter1_name = 'jane'
49 | commiter1_mail = 'janedoe@home'
50 | commiter1_sign = "1234567A"
51 | commiter1_sign_pref = True
52 |
53 | # Create a mock repo
54 | commiter = commiter1_name + ' <' + commiter1_mail + '>'
55 | repo_path = create_tmp_dir_with_repo(commiter)
56 |
57 | # Really commiter profile
58 | prof1_name = "sample1"
59 | prof1 = prof.Prof(profname=prof1_name,
60 | name=commiter1_name,
61 | email=commiter1_mail,
62 | signkey=commiter1_sign,
63 | signpref=commiter1_sign_pref)
64 |
65 | # Another sample profile
66 | prof2_name = "sample2"
67 | commiter2_name = 'Pepe García'
68 | commiter2_mail = 'pepe@none.aq'
69 | commiter2_sign = 'None'
70 | commiter2_sign_pref = False
71 | prof2 = prof.Prof(profname=prof2_name,
72 | name=commiter2_name,
73 | email=commiter2_mail,
74 | signkey=commiter2_sign,
75 | signpref=commiter2_sign_pref)
76 |
77 | gitcher.add_prof_fast(prof1_name, commiter1_name, commiter1_mail,
78 | commiter1_sign, commiter1_sign_pref)
79 | gitcher.add_prof_fast(prof2_name, commiter2_name,
80 | commiter2_mail, commiter2_sign,
81 | commiter2_sign_pref)
82 |
83 | model_layer.switch_prof(prof1.profname, path=str(repo_path))
84 | current_prof = model_layer.recuperate_git_current_prof(str(repo_path))
85 |
86 | self.assertEqual(prof1, current_prof)
87 |
88 | # Clean environment
89 | os.remove(cherfile_path[1])
90 | remove_tmp_dir(repo_path)
91 |
92 | def test_add_prof(self):
93 | """Simulates the add order to check the correct operative effect."""
94 |
95 | warnings.simplefilter("ignore",
96 | ResourceWarning) # Working with tmp files
97 |
98 | # Uses a mock tmp cherfile
99 | tmp_dir = tempfile.mkdtemp()
100 | cherfile_path = tempfile.mkstemp(dir=tmp_dir, prefix='tmp_cherfile')
101 | mock.patch('model_layer.CHERFILE', cherfile_path)
102 | model_layer.create_cherfile()
103 |
104 | # Commiter data to create the mock repo
105 | commiter1_name = 'jane'
106 | commiter1_mail = 'janedoe@home'
107 | commiter1_sign = "1234567A"
108 | commiter1_sign_pref = True
109 |
110 | # Create a mock repo
111 | commiter = commiter1_name + ' <' + commiter1_mail + '>'
112 | repo_path = create_tmp_dir_with_repo(commiter)
113 |
114 | # Really commiter profile
115 | prof1_name = "sample1"
116 | prof1 = prof.Prof(profname=prof1_name,
117 | name=commiter1_name,
118 | email=commiter1_mail,
119 | signkey=commiter1_sign,
120 | signpref=commiter1_sign_pref)
121 |
122 | # Another sample profile
123 | prof2_name = "sample2"
124 | commiter2_name = 'Pepe García'
125 | commiter2_mail = 'pepe@none.aq'
126 | commiter2_sign = 'None'
127 | commiter2_sign_pref = False
128 | prof2 = prof.Prof(profname=prof2_name,
129 | name=commiter2_name,
130 | email=commiter2_mail,
131 | signkey=commiter2_sign,
132 | signpref=commiter2_sign_pref)
133 |
134 | gitcher.add_prof_fast(prof1_name, commiter1_name, commiter1_mail,
135 | commiter1_sign, commiter1_sign_pref)
136 | gitcher.add_prof_fast(prof2_name, commiter2_name,
137 | commiter2_mail, commiter2_sign,
138 | commiter2_sign_pref)
139 |
140 | profs = model_layer.recuperate_profs()
141 | for x in [prof1, prof2]:
142 | self.assertTrue(x in profs)
143 |
144 | # Clean environment
145 | os.remove(cherfile_path[1])
146 | remove_tmp_dir(repo_path)
147 |
148 | def test_delete_prof(self):
149 | """Simulates the delete order to check the correct operative effect."""
150 |
151 | warnings.simplefilter("ignore",
152 | ResourceWarning) # Working with tmp files
153 |
154 | # Uses a mock tmp cherfile
155 | tmp_dir = tempfile.mkdtemp()
156 | cherfile_path = tempfile.mkstemp(dir=tmp_dir, prefix='tmp_cherfile')
157 | mock.patch('model_layer.CHERFILE', cherfile_path)
158 | model_layer.create_cherfile()
159 |
160 | # Commiter data to create the mock repo
161 | commiter1_name = 'jane'
162 | commiter1_mail = 'janedoe@home'
163 | commiter1_sign = "1234567A"
164 | commiter1_sign_pref = True
165 |
166 | # Create a mock repo
167 | commiter = commiter1_name + ' <' + commiter1_mail + '>'
168 | repo_path = create_tmp_dir_with_repo(commiter)
169 |
170 | # Really commiter profile
171 | prof1_name = "sample1"
172 | prof1 = prof.Prof(profname=prof1_name,
173 | name=commiter1_name,
174 | email=commiter1_mail,
175 | signkey=commiter1_sign,
176 | signpref=commiter1_sign_pref)
177 |
178 | # Another sample profile
179 | prof2_name = "sample2"
180 | commiter2_name = 'Pepe García'
181 | commiter2_mail = 'pepe@none.aq'
182 | commiter2_sign = 'None'
183 | commiter2_sign_pref = False
184 | prof2 = prof.Prof(profname=prof2_name,
185 | name=commiter2_name,
186 | email=commiter2_mail,
187 | signkey=commiter2_sign,
188 | signpref=commiter2_sign_pref)
189 |
190 | gitcher.add_prof_fast(prof1_name, commiter1_name, commiter1_mail,
191 | commiter1_sign, commiter1_sign_pref)
192 | gitcher.add_prof_fast(prof2_name, commiter2_name,
193 | commiter2_mail, commiter2_sign,
194 | commiter2_sign_pref)
195 |
196 | # Now, deletes prof2
197 | gitcher.delete_prof(prof2.profname)
198 |
199 | profs = model_layer.recuperate_profs()
200 | self.assertTrue(prof1 in profs)
201 | self.assertFalse(prof2 in profs)
202 |
203 | # Clean environment
204 | os.remove(cherfile_path[1])
205 | remove_tmp_dir(repo_path)
206 |
207 |
208 | if __name__ == '__main__':
209 | unittest.main()
210 |
211 |
212 | # ===============================================
213 | # = Test general util functions =
214 | # ===============================================
215 | def create_tmp_dir_with_repo(commiter: str) -> tempfile.TemporaryDirectory:
216 | """Creates a secure tmp directory with an init repository."""
217 | tmp_dir = tempfile.mkdtemp()
218 |
219 | # Now inits a sample repo
220 | repo = git.Repo.init(tmp_dir)
221 |
222 | # Create sample data
223 | for i in range(1, 5):
224 | tempfile.mkstemp(suffix='.py', dir=tmp_dir)
225 |
226 | repo.git.add('--all')
227 | repo.git.commit('-m', 'Commit test effects #1', author=commiter)
228 |
229 | return tmp_dir
230 |
231 |
232 | def remove_tmp_dir(tmp_dir: tempfile.TemporaryDirectory) -> None:
233 | shutil.rmtree(str(tmp_dir))
234 |
--------------------------------------------------------------------------------
/gitcher/model_layer.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | ###########################################################
4 | # Gitcher 3.2
5 | #
6 | # The git profile switcher
7 | #
8 | # Copyright 2019-2020 Borja González Seoane
9 | #
10 | # Contact: garaje@glezseoane.es
11 | ###########################################################
12 |
13 |
14 | """Gitcher's model layer module
15 |
16 | This module access and manipulate the 'CHERFILE', isolating this
17 | operations to the rest of the program.
18 | """
19 |
20 | import os
21 | import subprocess
22 | import operator
23 | from os.path import expanduser
24 | from shutil import which
25 |
26 | from gitcher.prof import Prof
27 | from gitcher.not_found_prof_error import NotFoundProfError
28 |
29 | # Paths
30 | HOME = expanduser('~')
31 | CHERFILE = HOME + '/.cherfile'
32 |
33 |
34 | # ===============================================
35 | # = CHERFILE model layer =
36 | # ===============================================
37 |
38 | def check_cherfile() -> bool:
39 | """Function that checks if CHERFILE exists.
40 |
41 | :return: Confirmation about the existence of CHERFILE
42 | :rtype: bool
43 | """
44 | return os.path.exists(CHERFILE)
45 |
46 |
47 | def create_cherfile() -> None:
48 | """Function that creates a CHERFILE.
49 |
50 | :return: None
51 | """
52 | open(CHERFILE, 'w')
53 | with open(CHERFILE, 'a') as f:
54 | print("####################\n"
55 | "# GITCHER CHERFILE #\n"
56 | "####################\n", file=f)
57 |
58 |
59 | def recuperate_profs() -> [Prof]:
60 | """Function that access CHERFILE and extracts profiles to Prof objects
61 | list. If there are not gitcher profiles in CHERFILE, returns an empty list.
62 | This function sorts profiles on alphabetical order looking its profname
63 | value.
64 |
65 | :return: A sort list with all gitcher profiles saved
66 | :rtype: [Prof]
67 | """
68 | profs = list()
69 | f = open(CHERFILE, 'r')
70 | lines = filter(None, (line.rstrip() for line in f)) # Not empty lines
71 | lines = [line for line in lines if not line.startswith('#')] # Not comment
72 | for line in lines:
73 | profname = line.split(",")[0]
74 | name = line.split(",")[1]
75 | email = line.split(",")[2]
76 | signkey = line.split(",")[3]
77 | signpref = line.split(",")[4].split("\n")[0]
78 |
79 | # Type conversions
80 | if signkey == "None":
81 | signkey = None
82 | signpref = (signpref == "True")
83 |
84 | prof = Prof(profname, name, email, signkey, signpref)
85 | profs.append(prof)
86 |
87 | return sorted(profs, key=operator.attrgetter('profname'))
88 |
89 |
90 | def recuperate_prof(profname: str) -> Prof:
91 | """ Function that return the required gitcher profile. If it does not
92 | exist, raise a not found exception.
93 |
94 | :param profname: Name of the gitcher profile to operate with
95 | :type profname: str
96 | :return: The required profile
97 | :rtype: Prof
98 | :raise: NotFoundProfError
99 | """
100 | profs = recuperate_profs()
101 | for prof in profs:
102 | if prof.profname == profname:
103 | return prof
104 |
105 | raise NotFoundProfError # If not founds profile and not returns before
106 |
107 |
108 | def save_profile(prof: Prof) -> None:
109 | """ Function that saves a new gitcher profile to the CHERFILE.
110 |
111 | :param prof: Gitcher profile to save
112 | :type prof: str
113 | :return: None
114 | """
115 | prof = [prof.profname, prof.name, prof.email, str(prof.signkey),
116 | str(prof.signpref)]
117 | prof_string = ','.join(prof)
118 | with open(CHERFILE, 'a') as f:
119 | print(prof_string, file=f)
120 |
121 |
122 | def delete_profile(profname: str) -> None:
123 | """ Function that deletes a gitcher profile from the CHERFILE.
124 |
125 | :param profname: Name of the gitcher profile to operate with
126 | :type profname: str
127 | :return: None
128 | """
129 | f = open(CHERFILE, 'r+') # Read and write mode
130 | lines = f.readlines()
131 | lines = [line.strip('\n') for line in lines]
132 | f.seek(0) # Return to the start of the file
133 | for line in lines:
134 | if line.split(',')[0] != profname:
135 | print(line, file=f)
136 | f.truncate() # Delete possible dirty lines below
137 | f.close()
138 |
139 |
140 | # ===============================================
141 | # = Git model layer =
142 | # ===============================================
143 |
144 | def check_git_installed() -> bool:
145 | """Function that checks if git command is installed and reachable.
146 |
147 | :return: Confirmation about the reachability of git command installation
148 | :rtype: bool
149 | """
150 | return which("git") is not None
151 |
152 |
153 | def check_git_context() -> bool:
154 | """Function that checks if the current directory have a git repository.
155 |
156 | :return: Confirmation about the presence of a git repository in the
157 | current directory
158 | :rtype: bool """
159 | cwd = os.getcwd()
160 | return os.path.exists(cwd + "/.git")
161 |
162 |
163 | # noinspection PyShadowingNames
164 | def switch_prof(profname: str, path: str = None, flag: str = '') -> None:
165 | """Function that plays the git profile switching.
166 |
167 | This function can receive a '--global' flag to switch profile globally.
168 |
169 | :param profname: Name of the gitcher profile to operate with
170 | :type profname: str
171 | :param path: The optional specified repository path
172 | :type path: str
173 | :param flag: With '--global' flag switch profile globally
174 | :type flag: str
175 | :return: None
176 | """
177 | if not path:
178 | path = os.getcwd() # Current working directory path
179 | prof = recuperate_prof(profname)
180 |
181 | go_to_cwd = "cd '{0}' && ".format(path)
182 | if flag == '--global':
183 | go_to_cwd = ""
184 |
185 | cmd = "{0}git config {1} user.name '{2}'".format(go_to_cwd, flag,
186 | prof.name)
187 | os.system(cmd)
188 |
189 | cmd = "{0}git config {1} user.email {2}".format(go_to_cwd, flag,
190 | prof.email)
191 | os.system(cmd)
192 |
193 | if prof.signkey is not None:
194 | cmd = "{0}git config {1} user.signingkey {2}". \
195 | format(go_to_cwd, flag, prof.signkey)
196 | os.system(cmd)
197 | else:
198 | cmd = "{0}git config {1} --unset user.signingkey". \
199 | format(go_to_cwd, flag)
200 | os.system(cmd)
201 |
202 | # Is necessary to run next command even preference is false because
203 | # it would be necessary overwrite git global criteria.
204 | cmd = "{0}git config {1} commit.gpgsign {2}". \
205 | format(go_to_cwd, flag, str(prof.signpref).lower())
206 | os.system(cmd)
207 |
208 |
209 | def recuperate_git_current_prof(path: str = None) -> Prof:
210 | """Function that recuperates the applicable git configuration of the
211 | param passed path and builds with this data a gitcher Prof. If param
212 | passed is None, then use the current working directory to evaluate it.
213 |
214 | Warnings:
215 | - The path must be assert before or function raises an error.
216 |
217 | :param path: Path to recuperates git user configuration
218 | :type path: str
219 | :return: Rebuilt git profile as gitcher Prof object
220 | :rtype: Prof
221 | """
222 | if path is None:
223 | path = os.getcwd()
224 | go_to_path = "cd '{0}' && ".format(path)
225 |
226 | with subprocess.Popen(go_to_path + "git config user.name",
227 | stdout=subprocess.PIPE, stderr=subprocess.PIPE,
228 | shell=True) as p:
229 | output, errors = p.communicate()
230 | name = output.decode('utf-8').split("\n")[0]
231 |
232 | with subprocess.Popen(go_to_path + "git config user.email",
233 | stdout=subprocess.PIPE, stderr=subprocess.PIPE,
234 | shell=True) as p:
235 | output, errors = p.communicate()
236 | email = output.decode('utf-8').split("\n")[0]
237 |
238 | with subprocess.Popen(go_to_path + "git config user.signingKey",
239 | stdout=subprocess.PIPE, stderr=subprocess.PIPE,
240 | shell=True) as p:
241 | output, errors = p.communicate()
242 | signkey = output.decode('utf-8').split("\n")[0]
243 |
244 | with subprocess.Popen(go_to_path + "git config commit.gpgsign",
245 | stdout=subprocess.PIPE, stderr=subprocess.PIPE,
246 | shell=True) as p:
247 | output, errors = p.communicate()
248 | signpref = output.decode('utf-8').split("\n")[0]
249 |
250 | # Validations
251 | if signkey == "":
252 | signkey = None
253 |
254 | if signpref == "true":
255 | signpref = True
256 | elif signpref == "false":
257 | signpref = False
258 |
259 | return Prof('tmp', name, email, signkey, signpref)
260 |
--------------------------------------------------------------------------------
/gitcher/__main__.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | ###########################################################
4 | # Gitcher 3.2
5 | #
6 | # The git profile switcher
7 | #
8 | # Copyright 2019-2020 Borja González Seoane
9 | #
10 | # Contact: garaje@glezseoane.es
11 | ###########################################################
12 |
13 | """Gitcher's main."""
14 |
15 | import os
16 | import readline
17 | import signal
18 | import sys
19 |
20 | from validate_email import validate_email
21 | from prettytable import PrettyTable
22 |
23 | from gitcher import model_layer, dictionary
24 | from gitcher.completer import TabCompleter
25 | from gitcher.prof import Prof
26 | from gitcher.not_found_prof_error import NotFoundProfError
27 |
28 | # Prompt styles
29 | COLOR_BLUE = '\033[94m'
30 | COLOR_BRI_BLUE = '\033[94;1m'
31 | COLOR_CYAN = '\033[96m'
32 | COLOR_BRI_CYAN = '\033[96;1m'
33 | COLOR_GREEN = '\033[92m'
34 | COLOR_RED = '\033[91m'
35 | COLOR_YELLOW = '\033[93m'
36 | COLOR_BOLD = '\033[1m'
37 | COLOR_RST = '\033[0m' # Restore default prompt style
38 |
39 | # Predefined messages
40 | MSG_OK = "[" + COLOR_GREEN + "OK" + COLOR_RST + "]"
41 | MSG_ERROR = "[" + COLOR_RED + "ERROR" + COLOR_RST + "]"
42 | MSG_WARNING = "[" + COLOR_YELLOW + "WARNING" + COLOR_RST + "]"
43 |
44 |
45 | # ===============================================
46 | # = Initial validations =
47 | # ===============================================
48 | # First, check if git is installed
49 | if not model_layer.check_git_installed():
50 | print(
51 | MSG_ERROR + " git is not installed in this machine. Impossible to "
52 | "continue.")
53 | sys.exit(1)
54 |
55 | # Next, check if CHERFILE exists. If not, create it
56 | if not model_layer.check_cherfile():
57 | model_layer.create_cherfile()
58 | print(MSG_OK + " Gitcher config dotfile created. Go on...")
59 |
60 |
61 | # Unique global instance for the execution gitcher dictionary
62 | dictionary = dictionary.Dictionary()
63 |
64 |
65 | # ===============================================
66 | # = Auxiliary functions =
67 | # ===============================================
68 | def quit_gracefully(signum, frame) -> None:
69 | """Function that prints a bye message. It is used to attach to escape
70 | signal (i.e.: Ctrl.+C) during the performance of the program. So, it
71 | is the exit function.
72 |
73 | :return: None, print function
74 | """
75 | print(COLOR_BLUE + "Bye!" + COLOR_RST)
76 | sys.exit(0)
77 |
78 |
79 | # Register previous function, linking it with Ctrl.+C
80 | signal.signal(signal.SIGINT, quit_gracefully)
81 |
82 |
83 | # noinspection PyShadowingNames
84 | def print_prof_error(profname: str) -> None:
85 | """Function that prints a nonexistent gitcher profile error.
86 |
87 | :param profname: Name of the gitcher profile to operate with
88 | :type profname: str
89 | :return: None, print function
90 | """
91 | print(MSG_ERROR + " Profile {0} not exists. Try again...".format(profname))
92 |
93 |
94 | def raise_order_format_error(arg: str = None) -> None:
95 | """Function that prints a command line format error advise and raises an
96 | exception. If arg is not specified, the function prints a complete order
97 | format error. If yes, raises an error advising the concrete argument
98 | implicated.
99 |
100 | :param arg: Implicated argument
101 | :type arg: str
102 | :return: None, print function
103 | :raise SyntaxError: Raise error by a bad order compose.
104 | """
105 | if arg is not None:
106 | adv = "Check param {0} syntax!".format(arg)
107 | print(MSG_ERROR + " " + adv)
108 | else:
109 | adv = "Check order syntax composition!"
110 | print(MSG_ERROR + " " + adv)
111 | sys.exit(1)
112 |
113 |
114 | def print_prof_list() -> None:
115 | """Function that prints the gitcher profile list.
116 |
117 | :return: None, print function
118 | """
119 | cprof = model_layer.recuperate_git_current_prof() # Current profile
120 | profs = model_layer.recuperate_profs()
121 | if profs: # If profs is not empty
122 | _, terminal_width = os.popen('stty size', 'r').read().split()
123 | terminal_width = int(terminal_width)
124 |
125 | """Catches the length of the largest compose profile to represent,
126 | taking the length of the largest attribute of each column."""
127 | big_atts = ['', '', '', '', '']
128 | for prof in profs:
129 | if len(prof.profname) > len(big_atts[0]):
130 | big_atts[0] = prof.profname
131 | if len(prof.name) > len(big_atts[1]):
132 | big_atts[1] = prof.name
133 | if len(prof.email) > len(big_atts[2]):
134 | big_atts[2] = prof.email
135 | if len(str(prof.signkey)) > len(big_atts[3]):
136 | big_atts[3] = str(prof.signkey)
137 | if len(str(prof.signpref)) > len(big_atts[4]):
138 | big_atts[4] = str(prof.signpref)
139 | big_prof_len = len(''.join(big_atts))
140 | big_prof_len += 16 # Spaces and bars to separate attributes
141 |
142 | if terminal_width >= big_prof_len: # Viable table representation
143 | """Switchs between table and list representations to avoid graphic
144 | crashes. Compares the terminal width with the length of the biggest
145 | profs list element."""
146 | profs_table = PrettyTable(['Prof', 'Name', 'Email',
147 | 'PGP key', 'Autosign'])
148 | for prof in profs:
149 | row = prof.tpl()
150 | if prof == cprof:
151 | row = [(COLOR_CYAN + profatt + COLOR_RST) for profatt in
152 | row]
153 | row[0] += "*"
154 | profs_table.add_row(row)
155 | print(profs_table)
156 | print("*: current in use gitcher profile.")
157 | else: # Not viable table representation
158 | for prof in profs:
159 | if prof == cprof:
160 | print("- " + COLOR_CYAN + prof.profname + ": " +
161 | prof.simple_str() + COLOR_RST + " [CURRENT]")
162 | else:
163 | print("- " + prof.profname + ": " + prof.simple_str())
164 | else:
165 | print("No gitcher profiles saved yet. Use 'a' option to add one.")
166 |
167 |
168 | def listen(question: str = None, autocompletion_context: [str] = None) -> str:
169 | """Function that listen an user input, validates it and then canalize
170 | message to caller function. This function also provides the support for
171 | autocompletion. To use it, its neccesary to pass as second param the
172 | context list of keys against match.
173 |
174 | :param question: Text of the question to the user
175 | :type question: str
176 | :param autocompletion_context: List of keys against match text to
177 | autocompletion. None to do not use this service
178 | :type autocompletion_context: [str]
179 | :return: User reply after canalize question via 'input()' function
180 | :rtype: str
181 | """
182 | if autocompletion_context: # Set autocompletion set
183 | # Init autocompletion support
184 | readline.set_completer_delims('\t')
185 | readline.parse_and_bind("tab: complete")
186 | completer = TabCompleter(autocompletion_context)
187 | readline.set_completer(completer.service)
188 |
189 | if question:
190 | reply = input(question).strip()
191 | else:
192 | reply = input().strip()
193 |
194 | if autocompletion_context: # Clean autocompletion set
195 | # noinspection PyUnboundLocalVariable
196 | completer = TabCompleter([])
197 | readline.set_completer(completer.service)
198 |
199 | try:
200 | check_syntax(reply)
201 | except SyntaxError:
202 | listen(question) # Recursive loop to have a valid value
203 |
204 | return reply
205 |
206 |
207 | def yes_or_no(question: str) -> bool:
208 | """Function that requires a yes or no answer
209 |
210 | :param question: Yes or no question to the user
211 | :type question: str
212 | :return: User reply
213 | :rtype: bool
214 | """
215 | reply = str(listen(question + " (y|n): ",
216 | autocompletion_context=['y', 'n'])).lower().strip()
217 | if reply[0] == 'y':
218 | return True
219 | if reply[0] == 'n':
220 | return False
221 | else:
222 | print(MSG_ERROR + " Enter (y|n) answer...")
223 | yes_or_no(question)
224 |
225 |
226 | def check_syntax(arg: str) -> None:
227 | """Check strings syntax. Gitcher does not avoid to use commas ','
228 | in string values.
229 |
230 | :param arg: Argument to check syntax
231 | :type arg: str
232 | :return: True or false
233 | :rtype: bool
234 | :raise SyntaxError: If arg is illegal
235 | """
236 | if ',' in arg: # The comma (',') is an illegal char
237 | print(MSG_ERROR + " Do not use commas (','), is an illegal char here.")
238 | raise SyntaxError("Do not use commas (',')")
239 |
240 |
241 | # noinspection PyShadowingNames
242 | def check_opt(opt_input: str,
243 | interactive_mode: bool = False,
244 | fast_mode: bool = False,
245 | whole: bool = False) -> bool:
246 | """Function that checks the integrity of the listen option. Options codes
247 | of the interactive and the fast mode can be passed.
248 |
249 | interactive_mode flag is to indicate that the check provides to an
250 | interactive_mode call.
251 |
252 | fast_mode flag is to indicate that the check provides to an fast_mode call.
253 |
254 | This flags act as switches to their respective modes. It is possible to
255 | combine various or even all modes simply by setting to True their
256 | respective flags. It is like the algebraic union operation.
257 |
258 | The whole flag traces the subscribed union of sets directly.
259 |
260 | Note that the default sets every flags to False, so the reply will be
261 | always False.
262 |
263 | :param opt_input: User input option
264 | :type opt_input: str
265 | :param fast_mode: Flag to indicate that the check is to validate from a
266 | fast mode call
267 | :type fast_mode: bool
268 | :param interactive_mode: Flag to indicate that the check is to validate
269 | from a interactive mode call
270 | :type interactive_mode: bool
271 | :param whole: Flag to check if the passed opt its valid for at least
272 | one of the modes
273 | :type whole: bool
274 | :return: Confirmation about the validation of the passed option
275 | :rtype: bool
276 | """
277 | opts_stock = [] # Initial empty
278 |
279 | # Expansions attending to config
280 | if whole:
281 | opts_stock.extend(dictionary.get_union_all())
282 | else:
283 | if interactive_mode:
284 | opts_stock.extend(dictionary.cmds_interactive_mode)
285 | if fast_mode:
286 | opts_stock.extend(dictionary.cmds_fast_mode)
287 |
288 | # Try to match
289 | if any(opt_input == opt_pattern for opt_pattern in opts_stock):
290 | return True
291 | else:
292 | return False
293 |
294 |
295 | # noinspection PyShadowingNames
296 | def check_profile(profname: str) -> bool:
297 | """Function that checks if a gitcher profile exists.
298 |
299 | :param profname: Name of the gitcher profile to operate with
300 | :type profname: str
301 | :return: Confirmation about the existence of gitcher profile required
302 | :rtype: bool
303 | """
304 | try:
305 | recover_prof(profname)
306 | return True
307 | except NotFoundProfError:
308 | return False # If not finds prof
309 |
310 |
311 | # noinspection PyShadowingNames
312 | def recover_prof(profname: str) -> Prof:
313 | """Function that recovers a gitcher profile through a model query.
314 |
315 | Warnings:
316 | - CHERFILE can not content two profiles with the same name. The add
317 | function takes care of it.
318 |
319 | :param profname: Name of the gitcher profile to operate with
320 | :type profname: str
321 | :return: gitcher profile required
322 | :rtype: Prof
323 | :raise: NotFoundProfError
324 | """
325 | try:
326 | return model_layer.recuperate_prof(profname)
327 | except NotFoundProfError:
328 | raise NotFoundProfError
329 |
330 |
331 | # ===============================================
332 | # = Main launchers =
333 | # ===============================================
334 |
335 | def list_profs() -> None:
336 | """Function that prints a list with saved profiles.
337 |
338 | :return: None, print function
339 | """
340 | profs = model_layer.recuperate_profs()
341 | if profs: # If profs is not empty
342 | for prof in profs:
343 | print("Profile " + prof.profname + ": " + prof.simple_str())
344 | else:
345 | print("No gitcher profiles saved yet. Use 'a' option to add one.")
346 |
347 |
348 | def show_current_on_prof() -> None:
349 | """Function that shows the current in use ON profile information.
350 |
351 | :return: None, print function
352 | """
353 | cprof = model_layer.recuperate_git_current_prof() # Current profile
354 |
355 | # Now, cprof is compared against saved profiles list. cprof is an
356 | # extract of the git user configuration, that is independent of the
357 | # gitcher data and scope. So, with next operations it is checked if
358 | # current config is saved on gitcher, and it is created a mixed dataset to
359 | # print the information
360 | profs = model_layer.recuperate_profs()
361 | for prof in profs:
362 | if cprof == prof:
363 | print("Profile " + prof.profname + ": " + cprof.simple_str())
364 | return
365 | # If not found in list...
366 | print(MSG_OK + " Unsaved profile: " + cprof.simple_str())
367 |
368 |
369 | # noinspection PyShadowingNames
370 | def set_prof(profname: str) -> None:
371 | """Function that sets the selected profile locally.
372 |
373 | It is imperative that it be called from a directory with a git
374 | repository. Profile name must be checked before.
375 |
376 | :param profname: Name of the gitcher profile to operate with
377 | :type profname: str
378 | :return: None
379 | """
380 | if model_layer.check_git_context():
381 | model_layer.switch_prof(profname)
382 | print(MSG_OK + " Switched to {0} profile.".format(profname))
383 | else:
384 | print(MSG_ERROR + " Current directory not contains a git repository.")
385 |
386 |
387 | # noinspection PyShadowingNames
388 | def set_prof_global(profname: str) -> None:
389 | """Function that sets the selected profile globally.
390 |
391 | It is not necessary to be called from a directory with a git repository.
392 | Profile name must be checked before.
393 |
394 | :param profname: Name of the gitcher profile to operate with
395 | :type profname: str
396 | :return: None
397 | """
398 | model_layer.switch_prof(profname, flag='--global')
399 | print(MSG_OK + " Set {0} as git default profile.".format(profname))
400 |
401 |
402 | # noinspection PyShadowingNames
403 | def add_prof() -> None:
404 | """Function that adds a new profile on interactive mode. Profile name
405 | have not to be checked before.
406 |
407 | :return: None
408 | """
409 | print("\nLets go to add a new gitcher profile...")
410 |
411 | profname = listen("Enter the profile name: ")
412 | while check_profile(profname):
413 | print(MSG_ERROR + " {0} yet exists. Change name...".format(profname))
414 | profname = listen("Enter profile name: ")
415 |
416 | name = listen("Enter the git user name: ")
417 |
418 | email = listen("Enter the git user email: ")
419 | while not validate_email(email):
420 | print(MSG_ERROR + " Invalid email format. Try again...".format(email))
421 | email = listen("Enter the git user email: ")
422 |
423 | if yes_or_no("Do you want to use a PGP sign key?"):
424 | signkey = listen("Enter the git user signkey: ")
425 | signpref = yes_or_no("Do you want to autosign every commit?")
426 | else:
427 | signkey = None
428 | signpref = False
429 |
430 | # Save it...
431 | prof = model_layer.Prof(profname, name, email, signkey, signpref)
432 | model_layer.save_profile(prof)
433 | print(MSG_OK + " New profile {0} added.".format(profname))
434 |
435 |
436 | # noinspection PyShadowingNames
437 | def add_prof_fast(profname: str, name: str, email: str, signkey: str,
438 | signpref: bool) -> None:
439 | """Function that adds a new profile on fast mode. Profile name have not
440 | to be checked before.
441 |
442 | :param profname:
443 | :type profname: str
444 | :param name:
445 | :type name: str
446 | :param email:
447 | :type email: str
448 | :param signkey:
449 | :type signkey: str
450 | :param signpref:
451 | :type signpref: bool
452 | :return: None
453 | """
454 | if not check_profile(profname): # Profname have to be unique
455 | prof = model_layer.Prof(profname, name, email, signkey, signpref)
456 | model_layer.save_profile(prof)
457 | print(MSG_OK + " New profile {0} added.".format(profname))
458 | else:
459 | print(MSG_ERROR + " {0} yet exists!".format(profname))
460 | sys.exit(1)
461 |
462 |
463 | # noinspection PyShadowingNames
464 | def update_prof() -> None:
465 | """Function that updates a profile on interactive mode. Profile name
466 | have not to be checked before.
467 |
468 | :return: None
469 | """
470 | print("\nLets go to update a gitcher profile...")
471 |
472 | old_profname = listen("Enter the profile name: ",
473 | dictionary.profs_profnames)
474 | while not check_profile(old_profname):
475 | print(MSG_ERROR + " {0} not exists. Change name...".format(
476 | old_profname))
477 | old_profname = listen("Enter profile name: ",
478 | dictionary.profs_profnames)
479 |
480 | prof = model_layer.recuperate_prof(old_profname)
481 |
482 | profname = old_profname
483 | if yes_or_no("Do you want to update the profile name?"):
484 | profname = listen("Enter the new profile name: ")
485 | name = prof.name
486 | if yes_or_no("Do you want to update the user name?"):
487 | name = listen("Enter the new name: ")
488 | email = prof.email
489 | if yes_or_no("Do you want to update the user email?"):
490 | email = listen("Enter the new email: ")
491 | while not validate_email(email):
492 | print(MSG_ERROR + " Invalid email format. Try again...".format(
493 | email))
494 | email = listen("Enter the new email: ")
495 | if yes_or_no("Do you want to update the PGP sign config?"):
496 | if yes_or_no("Do you want to use a PGP sign key?"):
497 | signkey = listen("Enter the git user signkey: ")
498 | signpref = yes_or_no("Do you want to autosign every commit?")
499 | else:
500 | signkey = None
501 | signpref = False
502 | else:
503 | signkey = prof.signkey
504 | signpref = prof.signpref
505 |
506 | # Remove the old profile
507 | model_layer.delete_profile(old_profname)
508 | # And save the new...
509 | prof = model_layer.Prof(profname, name, email, signkey, signpref)
510 | model_layer.save_profile(prof)
511 | print(MSG_OK + " Profile {0} updated.".format(profname))
512 |
513 |
514 | # noinspection PyShadowingNames
515 | def mirror_prof(origin_profname: str) -> None:
516 | """Function that mirrors a profile to create a duplicate of it.
517 |
518 | Profile name must be checked before.
519 |
520 | :param origin_profname: Name of the gitcher profile to operate with
521 | :type origin_profname: [str]
522 | :return: None
523 | """
524 | new_profname = listen("Enter the new profile name (can not be the same "
525 | "that the origin profile): ")
526 | while check_profile(new_profname):
527 | print(MSG_ERROR + " {0} yet exists. Change name...".format(
528 | new_profname))
529 | new_profname = listen("Enter profile name: ")
530 |
531 | prof = model_layer.recuperate_prof(origin_profname)
532 |
533 | profname = new_profname
534 | name = prof.name
535 | email = prof.email
536 | signkey = prof.signkey
537 | signpref = prof.signpref
538 |
539 | # Save the new profile...
540 | prof = model_layer.Prof(profname, name, email, signkey, signpref)
541 | model_layer.save_profile(prof)
542 | print(MSG_OK + " Profile {0} created.".format(profname))
543 |
544 |
545 | # noinspection PyShadowingNames
546 | def delete_prof(profname: str) -> None:
547 | """Function that deletes the selected profile.
548 |
549 | Profile name must be checked before.
550 |
551 | :param profname: Name of the gitcher profile to operate with
552 | :type profname: [str]
553 | :return: None
554 | """
555 | model_layer.delete_profile(profname)
556 | print(MSG_OK + " Profile {0} deleted.".format(profname))
557 |
558 |
559 | # ===============================================
560 | # = MAIN =
561 | # ===============================================
562 |
563 | def interactive_main() -> None:
564 | """Main launcher of gitcher program interactive mode. Dialogue with the
565 | user.
566 |
567 | :return: None
568 | """
569 | print(COLOR_BRI_BLUE + "**** gitcher: the git profile switcher ****" +
570 | COLOR_RST)
571 |
572 | print("gitcher profiles list:")
573 | print_prof_list()
574 | print("\nOptions:")
575 | print(COLOR_BRI_CYAN + "s" + COLOR_RST + " set a profile to current "
576 | "directory repository.")
577 | print(COLOR_BRI_CYAN + "g" + COLOR_RST + " set a profile as global "
578 | "git configuration.")
579 | print(COLOR_BRI_CYAN + "a" + COLOR_RST + " add a new profile.")
580 | print(COLOR_BRI_CYAN + "u" + COLOR_RST + " update a profile.")
581 | print(COLOR_BRI_CYAN + "m" + COLOR_RST + " mirror a profile to create a"
582 | " duplicate.")
583 | print(COLOR_BRI_CYAN + "d" + COLOR_RST + " delete a profile.")
584 | print(COLOR_BRI_CYAN + "q" + COLOR_RST + " quit. Also can use " +
585 | COLOR_BRI_CYAN + "Ctrl.+C" + COLOR_RST + " everywhere.\n")
586 |
587 | opt = listen("Option: ", dictionary.get_union_cmds_set())
588 | while not check_opt(opt, interactive_mode=True):
589 | print(MSG_ERROR + " Invalid opt! Use " +
590 | '|'.join(dictionary.cmds_interactive_mode) +
591 | ". Type exit to quit.")
592 | opt = listen("Enter option: ", dictionary.get_union_cmds_set())
593 |
594 | if opt == 'q': # Always quite
595 | print(COLOR_BLUE + "Bye!" + COLOR_RST)
596 | sys.exit(0)
597 | if not opt == 'a' and not opt == 'u':
598 | profname = listen("Select the desired profile entering its name: ",
599 | dictionary.profs_profnames)
600 | while not check_profile(profname):
601 | print_prof_error(profname)
602 | profname = listen("Enter profile name: ",
603 | dictionary.profs_profnames)
604 |
605 | if opt == 's':
606 | set_prof(profname)
607 | elif opt == 'g':
608 | set_prof_global(profname)
609 | elif opt == 'm':
610 | mirror_prof(profname)
611 | else: # Option 'd'
612 | if yes_or_no(MSG_WARNING + " Are you sure to delete {0}?".format(
613 | profname)):
614 | delete_prof(profname)
615 | else:
616 | if opt == 'a':
617 | add_prof()
618 | else: # Option 'u'
619 | update_prof()
620 |
621 | print("\n") # Graphical interaction separator in loop context
622 |
623 |
624 | def fast_main(cmd: [str]) -> None:
625 | """Runs fast passed options after to do necessary checks.
626 |
627 | :param cmd: Command line order by the user
628 | :type cmd: [str]
629 | :return: None
630 | """
631 | # First, check param syntax
632 | for param in cmd:
633 | try:
634 | check_syntax(param)
635 | except SyntaxError:
636 | sys.exit("Syntax error")
637 |
638 | # If syntax is ok, go on and check selected option
639 | opt = cmd[1].replace('-', '')
640 | if not check_opt(opt, fast_mode=True):
641 | print(MSG_ERROR + " Invalid option! Use -[" +
642 | '|'.join(dictionary.cmds_fast_mode) + "]")
643 | sys.exit(1)
644 | else:
645 | if opt == 'o':
646 | if len(cmd) == 2: # cmd have to be only 'gitcher <-o>'
647 | show_current_on_prof()
648 | else:
649 | raise_order_format_error()
650 | elif opt == 'l':
651 | if len(cmd) == 2: # cmd have to be only 'gitcher <-l>'
652 | list_profs()
653 | else:
654 | raise_order_format_error()
655 | elif len(cmd) >= 3: # cmd have to be 'gitcher <-opt> [...]'
656 | # Catch profname, first parameter for all cases
657 | profname = cmd[2]
658 |
659 | if opt == 'a':
660 | if len(cmd) != 7: # cmd have to be 'gitcher <-opt>
661 | # '
662 | raise_order_format_error()
663 | # Catch specific params
664 | name = cmd[3]
665 | email = cmd[4]
666 | if not validate_email(email):
667 | raise_order_format_error(email)
668 | signkey = cmd[5]
669 | if signkey == 'None':
670 | signkey = None
671 | signpref = cmd[6]
672 | if signpref == 'True':
673 | signpref = True
674 | elif signpref == 'False':
675 | signpref = False
676 | else:
677 | raise_order_format_error(cmd[5])
678 |
679 | add_prof_fast(profname, name, email, signkey, signpref)
680 | else: # Else it is always necessary to check the profile
681 | if len(cmd) == 3: # Security check
682 | if not check_profile(profname):
683 | print_prof_error(profname)
684 | sys.exit(1)
685 | # Else, if the profile exists, continue...
686 | if opt == 's':
687 | set_prof(profname)
688 | elif opt == 'g':
689 | set_prof_global(profname)
690 | elif opt == 'd':
691 | delete_prof(profname)
692 | else:
693 | raise_order_format_error()
694 | else:
695 | raise_order_format_error()
696 |
697 |
698 | def main():
699 | if (len(sys.argv)) == 1: # Interactive mode, closure execution in a loop
700 | while True: # The user inputs the exit order during the session
701 | interactive_main()
702 | elif (len(sys.argv)) > 1: # Fast mode
703 | fast_main(sys.argv)
704 |
705 |
706 | if __name__ == "__main__":
707 | main()
708 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 | gitcher
635 | Copyright (C) 2019-2020 Borja González Seoane
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | gitcher Copyright (C) 2019-2020 Borja González Seoane
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------