Git Product home page Git Product logo

gitdriver's Introduction

Synopsis

gitdriver.py [-h] [--config CONFIG] [--text] [--html] docid

Options

  • --config CONFIG, -f CONFIG -- path to configuration file
  • --text, -T -- fetch plain text content (Look out for BOM)
  • --html, -H -- fetch HTML content
  • --mime-type -- specify arbitrary mime type

Example usage:

$ python gitdriver.py 1j6Ygv0_this_is_a_fake_document_id_a8Q66mvt4
Create repository "Untitled"
Initialized empty Git repository in /home/lars/projects/gitdriver/Untitled/.git/
[master (root-commit) 27baec9] revision from 2013-01-08T21:57:38.837Z
 1 file changed, 1 insertion(+)
 create mode 100644 content
[master 132175a] revision from 2013-01-08T21:57:45.800Z
 1 file changed, 1 insertion(+), 1 deletion(-)
[master eb2302c] revision from 2013-01-09T01:47:29.593Z
 1 file changed, 5 insertions(+), 1 deletion(-)
$ ls Untiled
content
$ cd Untitled
$ git log --oneline
d41ad6e revision from 2013-01-09T01:47:29.593Z
8d3e3ec revision from 2013-01-08T21:57:45.800Z
ccc0bdd revision from 2013-01-08T21:57:38.837Z

Google setup

You will need to create an OAuth client id and secret for use with this application, the Drive API Python quickstart has links to the necessary steps.

Configuration

In order to make this go you will need to create file named gd.conf where the code can find it (typically the directory in which you're running the code, but you can also use the -f command line option to specify an alternate location).

The file is a simple YAML document that should look like this:

googledrive:
  client id: YOUR_CLIENT_ID
  client secret: YOUR_CLIENT_SECRET

Where YOUR_CLIENT_ID and YOUR_CLIENT_SECRET are replaced with the appropriate values from Google that you established in the previous step.

gitdriver's People

Contributors

dlazesz avatar larsks avatar timwis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gitdriver's Issues

support non-ASCII characters in usernames

If I try to run gitdriver, it fails with the following error:

Traceback (most recent call last):
  File "gitdrive.py", line 114, in <module>
    main()
  File "gitdrive.py", line 112, in main
    commit_revision(gd, opts, rev)
  File "gitdrive.py", line 68, in commit_revision
    rev['lastModifyingUserName'])], env=env)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in position 8: ordinal not in range(128)

If I'm understanding it right, this is because my Google username (lastModifyingUserName) includes the character ü. Would be nice if non-ASCII characters could be supported.

KeyError: 'text/html'

Hello!

If I run (like the example):

➜  gitdriver git:(master) ✗ env/bin/python gitdriver.py MY_DOC_ID 

I get the following output:

Exactly one mime-type must be given!

When I add the -T/--text flag, or specify --mime-type=text/html, I get the following output:

Create repository "MY_DOC_TITLE"
Initialized empty Git repository in /Users/rosenbek/Desktop/temp/gitdriver/MY_DOC_TITLE/.git/
Traceback (most recent call last):
  File "gitdriver.py", line 72, in <module>
    main()
  File "gitdriver.py", line 55, in main
    r = gd.session.get(rev['exportLinks'][opts.mime_type])
KeyError: 'text/html'

Any thoughts what might be going on?

I am trying to clone a Google Sheet, if it's any help.

Thanks for the good idea on this repo!

KeyError: 'items'

After inserting the code from the webpage as requested:

Enter code: xxxxxxxxxxxxxxxxxxxx Create repository "PRXXX" Initialized empty Git repository in C:/Users/Torre/BrainCrack/gitdriver/PRXXX/.git/ Traceback (most recent call last): File "gitdriver.py", line 74, in <module> main() File "gitdriver.py", line 52, in main for rev in gd.revisions(opts.docid): File "C:\Users\Torre\BrainCrack\gitdriver\drive.py", line 169, in revisions for rev in r['items']: KeyError: 'items'

Integrate progress from forks

The are several forks of this project which all fix various issues and extend the features, several of the accomplishing the same thing in different ways or with a different combinations of features.

It would be really nice to get them cleaned up and integrated into one fork. Python 3 support seems to have been done several times, updating rather than starting from scratch on each run has been done at least twice, there are three iterations of getting author information, mime types have been extended several times, and one complete repost (not listed in the forks) has a some Unicode issues worked out and doesn't die on odd entries in the revisions history such as deleted users.

Are you interested in integrating these into this repository? Are you interested in getting help doing that (yes I might volunteer)? Or are you pretty much done with it and should I look into who else wants to collaborate?

Idea: add markdown support via pandoc

I've found that pandoc does a surprisingly good job of converting Google Docs documents with complicated tables, headings, bullet lists, etc. into reasonable-looking Markdown files (with a few formatting issues that can be cleaned up via a script or via markdown linting) if you use the Github-flavored markdown output format and convert from docx. For example:

pandoc -f docx -t gfm -o MyDocument.md MyDocument.docx

I'd like to implement a --markdown flag in gitdriver that would download the Google Doc using docx mime type, then include an extra step of converting to Github-flavored markdown using pandoc and cleaning up the intermediate docx file. Is that something you'd be interested in adding?

Pro: Your users would now have markdown as an output format option

Con: Some of the inevitable formatting issues that occur when going from docx to markdown may surprise users (violating principle of least-surprise). But warning the user should take care of this.


As an example of the kind of formatting issues I'm referring to:

If there is a line with bold text, and it ends in a space, the space is not ignored, so you end up with the following (invalid) attempt at making the text in the Markdown file bold:

**This is some bold text. **

which does not render correctly in Markdown:

**This is some bold text. **

Bullet list items that span multiple lines have blockquote > in front of them, e.g.,

  • Inventore sit non voluptas quidem. Aut nobis fuga facilis rerum et nisi cupiditate ut. Quod quisquam deserunt et ipsum aut velit et numquam. Nihil ab dolorem molestiae dolore voluptate. Et aut ea veritatis velit ipsa repellendus.

  • Architecto repudiandae eius sunt ipsa. Quos non dicta id nihil quaerat veniam est sed. Illum laboriosam accusantium dolores totam fugiat animi iusto nihil. Facilis dolores libero mollitia impedit minus iste.

Those are the main two I noticed, there may be a few others but they're minor by comparison.

KeyError: 'HOME' with drive.py

I have created an OAuth client id and secret along with gd.conf, but I get this error:

Traceback (most recent call last):
  File "gitdriver.py", line 72, in <module>
    main()
  File "gitdriver.py", line 34, in main
    scopes=[DRIVE_RW_SCOPE],
  File "C:\Users\EnragedViper\Downloads\gitdriver-master\gitdriver-master\drive.py", line 42, in __init__
    credentials = os.path.join(os.environ['HOME'], '.googledrive')
  File "C:\Python27\lib\os.py", line 425, in __getitem__
    return self.data[key.upper()]
KeyError: 'HOME'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.