Skip to content

Commit

Permalink
working on setup.py
Browse files Browse the repository at this point in the history
  • Loading branch information
chidimo committed Mar 19, 2018
1 parent de38ed3 commit f40e658
Show file tree
Hide file tree
Showing 19 changed files with 1,914 additions and 2 deletions.
178 changes: 178 additions & 0 deletions PyGit.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
Metadata-Version: 1.1
Name: PyGit
Version: 3.0
Summary: Automate common git tasks
Home-page: UNKNOWN
Author: Chidi Orji
Author-email: orjichidi95@gmail.com
License: MIT
Description: # PyGit
============

Automate the boring git stuff with python

## Motivation

Whenever I wanted to see the status of all my git repos I have to fire up the
`git-cmd.exe` shell on windows, navigate to each folder and then do a `git status`.
I have to do this both at home and at work.

But I got quickly tired of it. So I decided to make this tool to give me a quick
report so I can see what is ahead and what's behind and what's ahead at a glance.
In short, what needs attention so as to avoid those troubling merge conflicts.

## Requirements

The only requirements in terms of software is `send2trash` which helps take care of cleaning up stuff.
Other thing you need is a computer with `git` accessible from the command line. If you're on a computer
where you don't have permission to install stuff, you can do with a portable `git` and `pygit` will work just fine.

You can get a portable git version from [here](https://git-scm.com/download/win)

Just unzip it and place it somewhere on your disk. You'll need to tell `pygit` where this file is during intitialization.


## Installation

Github, `pip install https://github.com/immensity/pygit/archive/3.0.tar.gz` or PyPI `pip install pygit --upgrade`

## Usage

Upon successful installation do

import pygit

A successful import returns a blank screen.

To use `pygit`, you have to tell it where your `git` repositories are. You may do this by passing it a list of strings on the command line.
Each string represents a full path name to single directory.

If you have a master directory that holds multiple `git` repositories, `pygit` can also take the full path name of this master directory
and then index the git repositories it finds there. It won't index those directories that are not git repos.

It is also possible to tell `pygit` not to index certain directories by specifying the starting string of the directory name. This is referred
to s a `rule`. Directories matching such rules will not be touched.




To initialize `pygit`, run

pygit.initialize()

In case things change (perhaps you moved folders around) and you want to reset your folders,
just run the `set_all()` command again


To see all available repositories run ::

pygit.show_repos()

This command shows a list of all available repositories in the format ::

repository_id: repository_name: repository_directory_path

To load a particular repository use ::

pygit.load(repo_id_or_name)

where **repo_id** is a string-valued id assigned to that particular repo. The first value in the `show_repos` command's output.


The **load\(\)** command returns a `Commands` object for that repo, which provides a gateway for issuing git commands on the repository

Operations that can be performed on `Commands` object are shown below. ::

Commands().fetch() # perform fetch.

Commands().status() # see status

Commands().add_all() # stage all changes for commit

Commands().commit(message='minor changes') # commit changes. Press enter to accept default message

Commands().push() # perform push action

Commands().pull() # perform pull request

Commands().add_commit() # add and commit at once



### Batch Operations

Pygit provides some functions for performing batch operations on your repositories. ::

pygit.load_multiple(*args)

loads a set of repositories. You could decide to only load only 2 of 10 repositories. Perhaps you need to perform similar actions
on those two alone. As an example

pygit.load_set("2", "5")

returns a `generator` of `Commands` objects for repositories 2 and 5. Afterwards you can use a :py:func:`for` loop to iterate over the repos
like below

for each in pygit.load_set("2", "5"):
each.add_commit()

pygit.all_status()


performs a **status** command on all your repositories. The result is written to a text file. The text file opens automatically.
The name of the file shows the date and time of the status request. All batch status request is written to its a separate file.
Call it a snapshot of your repo status if you will
Those items which are out of sync with their remote counterpart (by being ahead or being behind) are also highlighted as needing attention. ::

pygit.pull_all()


performs a **pull** request on all your repositories at once. Its `return` value is None. ::

pygit.push_all()


performs a **push** action on all your repositories at once. Its `return` value is None. ::

pygit.load_all()


returns a `generator` of `Commands` object for every repository.


API
=====
.. automodule :: pygit.api
:members:

Commands
=============

.. automodule :: pygit.commands
:members:

Utility Functions
=======================

.. automodule :: pygit.utils
:members:

To do
======

Add **git-bash.exe**

Implement Commands.branch()

Find out why importing pygit for first time gives an PermissionError
Write tests

Run test after importation to make sure every other thing works fine.

Define an update function that updates the repo dictionaries for the case when a new repo is added but the overall directory structure remains unchanged.

Keywords: git and github task automation
Platform: UNKNOWN
Classifier: Developement Status :: 3 - Alpha
Classifier: Programming Language :: Python :: 3.6.1
Classifier: Topic :: Git :: Automation
16 changes: 16 additions & 0 deletions PyGit.egg-info/SOURCES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
MANIFEST.in
README.rst
license.txt
setup.py
PyGit.egg-info/PKG-INFO
PyGit.egg-info/SOURCES.txt
PyGit.egg-info/dependency_links.txt
PyGit.egg-info/not-zip-safe
PyGit.egg-info/requires.txt
PyGit.egg-info/top_level.txt
pygit/__init__.py
pygit/binn.py
pygit/main.py
pygit/new.py
pygit/select_directory.py
pygit/test.py
1 change: 1 addition & 0 deletions PyGit.egg-info/dependency_links.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions PyGit.egg-info/not-zip-safe
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions PyGit.egg-info/requires.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
send2trash
1 change: 1 addition & 0 deletions PyGit.egg-info/top_level.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pygit
8 changes: 8 additions & 0 deletions UNKNOWN.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Metadata-Version: 1.0
Name: UNKNOWN
Version: 0.0.0
Summary: UNKNOWN
Home-page: UNKNOWN
License: UNKNOWN
Description: UNKNOWN
Platform: UNKNOWN
8 changes: 8 additions & 0 deletions UNKNOWN.egg-info/SOURCES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
MANIFEST.in
README.rst
license.txt
setup.py
UNKNOWN.egg-info/PKG-INFO
UNKNOWN.egg-info/SOURCES.txt
UNKNOWN.egg-info/dependency_links.txt
UNKNOWN.egg-info/top_level.txt
1 change: 1 addition & 0 deletions UNKNOWN.egg-info/dependency_links.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions UNKNOWN.egg-info/top_level.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

9 changes: 9 additions & 0 deletions build/lib/pygit/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"""Docstring"""

from .main import (
cleanup, check_git_support, is_git_repo, need_attention, initialize,
Commands, show_repos, load, load_multiple, pull, push, all_status
)

__all__ = ["all_status", "cleanup", "check_git_support", "is_git_repo", "need_attention", "initialize",
"Commands", "show_repos", "load", "load_multiple", "pull", "push", "all_status"]
45 changes: 45 additions & 0 deletions build/lib/pygit/binn.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
"""Graphical directory selection"""

try:
import tkinter as tk
from tkinter import filedialog
except ImportError:
print("tkinter was not found.")
pass


def select_directory(title="Select directory"):
"""Select and return a directory path"""
try:
root = tk.Tk()
root.withdraw()
initialdir = "/"
root_dir = filedialog.askdirectory(parent=root,
initialdir=initialdir,
title=title)
except:
print("Tk inter was not found.")
return root_dir

import os, sys, site

# https://stackoverflow.com/questions/36187264/how-to-get-installation-directory-using-setuptools-and-pkg-ressources
def binaries_directory():
"""Return the installation directory, or None"""
if '--user' in sys.argv:
paths = (site.getusersitepackages(),)
else:
py_version = '%s.%s' % (sys.version_info[0], sys.version_info[1])
paths = (s % (py_version) for s in (
sys.prefix + '/lib/python%s/dist-packages/',
sys.prefix + '/lib/python%s/site-packages/',
sys.prefix + '/local/lib/python%s/dist-packages/',
sys.prefix + '/local/lib/python%s/site-packages/',
'/Library/Python/%s/site-packages/',
))

for path in paths:
if os.path.exists(path):
return path
print('no installation path found', file=sys.stderr)
return None

0 comments on commit f40e658

Please sign in to comment.