![]() |
#1051 | |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,788
Karma: 6000000
Join Date: Nov 2009
Device: many
|
Hi,
Thanks for the help, but I would need to do that for each of the 60 commits so I might as well just erase the whole thing and start again since setting the author for each commit is needed, right? It would be safer I think anyway. Also, can you assign more than 1 author for a single commit? Thanks, KevinH Quote:
|
|
![]() |
![]() |
![]() |
#1052 | |
Ex-Helpdesk Junkie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 19,421
Karma: 85400180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
Quote:
Sure you can start over. But currently you have the actual contents of the commits the way you want them, correct? rebase allows you to keep the content and just edit the metadata of the commits. (It does other things too, of course. ![]() It's really easy to edit the author each time, just hit the up arrow in your terminal, right-arrow a few times and edit the --author flag. ![]() Oh yes. If you want to preserve the commitmsg but remove the extraneous authorinfo, you should use --edit -m instead, but once again setting a blank email seems to break. You should probably just use Code:
git commit --amend --author="Adam Selene <none>" && git rebase --continue
I just love the inconsistency. Really. EDIT (again): I like the answer below. You might want to use Code:
--msg-filter 'sed -e "/Authors[^,]*$/d"' Last edited by eschwartz; 10-15-2014 at 03:06 PM. |
|
![]() |
![]() |
Advert | |
|
![]() |
#1053 |
but forgot what it's like
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 741
Karma: 2345678
Join Date: Dec 2011
Location: north (by northwest)
Device: Kindle Touch
|
Hope this will help.
Here is a Python 3 script for printing author name basing on your commit message format: Spoiler:
It could be tested with: Code:
$ git log -n1 <commit_id> | python3 authors.py Code:
$ git log -n1 af0740a3 | python3 authors.py Kevin Hendricks $ git log -n1 80150331 | python3 authors.py Kevin Hendricks $ git log -n1 7b32b687 | python3 authors.py tkeo $ git log -n1 91d3e282 | python3 authors.py Various authors Code:
--env-filter 'export GIT_AUTHOR_NAME="$(git log -n1 ${GIT_COMMIT} | python3 /full/path/to/authors.py)"; if [ "x${GIT_AUTHOR_NAME}" != "xKevin Hendricks" ]; then export GIT_AUTHOR_EMAIL=""; fi' Spoiler:
I guess, author of the very first commit should be fixed manually. I think, Git allows only for one author in commit field, so historical information about authors shouldn't be removed from commit messages. Last edited by eureka; 10-15-2014 at 02:47 PM. Reason: put current original commit ids into authors.py example |
![]() |
![]() |
![]() |
#1054 |
Ex-Helpdesk Junkie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 19,421
Karma: 85400180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
|
![]() |
![]() |
![]() |
#1055 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,788
Karma: 6000000
Join Date: Nov 2009
Device: many
|
Hi eschwartz,
Thank you! That is worth trying on my local tree but since we have no real e-mail addresses anyway, I will try creating a combined "author" field when more than one author is listed. I saw where some companies are doing this for their "pairs" approach to programming. I also saw there is a long-running bug report in git to allow multiple authors for a single commit. So changing Author: Various authors <> To something along the lines of: Author: "DiapDealer, tkeo"<> or Author: "DiapDealer & tkeo"<> If that works, then I will definitely give this a try. Thanks, KevinH |
![]() |
![]() |
Advert | |
|
![]() |
#1056 | |
but forgot what it's like
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 741
Karma: 2345678
Join Date: Dec 2011
Location: north (by northwest)
Device: Kindle Touch
|
Quote:
Spoiler:
It recognizes a bit different input line, as provided by: Code:
--env-filter 'export GIT_AUTHOR_NAME="$(git cat-file -p ${GIT_COMMIT} | python3 /full/path/to/authors.py)"; if [ "x${GIT_AUTHOR_NAME}" != "xKevin Hendricks" ]; then export GIT_AUTHOR_EMAIL=""; fi' Code:
for commit_id in `git log --format='format:%H'`; do git cat-file -p $commit_id | python3 authors.py; done UPD2: as eschwartz demonstrated, --author option of git commit doesn't accept empty email without commit message also being set with command-line option. Maybe some other Git-related commands/tools have similar small idiosyncrasies?... It might be better/safer to set invalid email instead of empty email. Last edited by eureka; 10-15-2014 at 06:55 PM. Reason: mild script change |
|
![]() |
![]() |
![]() |
#1057 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,788
Karma: 6000000
Join Date: Nov 2009
Device: many
|
github now with author information
Hi All,
A very special thanks to both eschwartz and eureka for their invaluable help figuring out how to edit the commit metadata and for developing authors.py. I have now used these tools on my own tree. I decided to keep the Authors information in the commit messages since some commits are actually multiple releases and this way people will know who committed what. I still violate the 50 char rule (argh!) and the initial capitalization rule but since these are historic commits imported from outside of GitHub, I am hoping no one will mind too much. I will try to use both the 50 char limit and first word capitalized rules for all new commits to the tree. Hope everyone is now happy with the result. https://github.com/kevinhendricks/KindleUnpack Thanks, KevinH |
![]() |
![]() |
![]() |
#1058 |
but forgot what it's like
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 741
Karma: 2345678
Join Date: Dec 2011
Location: north (by northwest)
Device: Kindle Touch
|
Out of curiosity I've tried to run flake8 on KindleUnpack codebase:
Spoiler:
I did this not for blaming purposes. I understand that KindleUnpack is working code useful for many people in current state, so it's a practically good code. But this list possibly contains some low-hanging fruits. |
![]() |
![]() |
![]() |
#1059 |
KCC Co-Author
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 845
Karma: 765434
Join Date: Mar 2013
Location: Poland
Device: Kindle Oasis 2
|
eureka beat me to it. I also was planning to bring up this topic.
Today I will make Pull Request to Python3 branch with cleaned/PEP8 compliant code. At the same time KevinH will have chance to look how GitHub support code contributions. Edit: I presume that Python3 branch is not yet ready? Because I see multiple places where sytax not supported by Python 3.4 is used. Edit 2: 2188 Python 2.x PEP8 style violations. *Cough*. That pull request might not be ready today :-P Last edited by AcidWeb; 10-16-2014 at 03:12 AM. |
![]() |
![]() |
![]() |
#1060 | |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,788
Karma: 6000000
Join Date: Nov 2009
Device: many
|
Hi,
The code to allow KindleUnpack to work on *BOTH* Python 2.7 and Python 3.4 is incomplete, but runnable from the command line. It is in the python2and3 branch. And yes 2to3 will scream at it but that is expected and does actually run on both. I will run reindent.py on the master to clean up most of the spacing issues. It was run but only the python2and3 branch. That was done so all serious whitespace issues should be taken care of. As for flake8 - it is simply a style enforcer. And McCabe's complexity analysis is for the birds as well. You can tell if code is maintainable by simply reading it. For example numerous "errors" in mobi_header.py are: Code:
id_map_strings = { 1 : 'Drm Server Id (1)', 2 : 'Drm Commerce Id (2)', 3 : 'Drm Ebookbase Book Id(3)', 100 : 'Creator_(100)', 101 : 'Publisher_(101)', 102 : 'Imprint_(102)', 103 : 'Description_(103)', 104 : 'ISBN_(104)', 105 : 'Subject_(105)', 106 : 'Published_(106)', Sorry but that's not gonna change! The change itself would be meaningless (no impact on pyc execution) and the spacing helps to make things look cleaner. I *will* look at the unused variables and more serious cdll issues and other issues that flake8 picks up but style only changes in whitespace or "line too long" changes will be ignored. So please don't bother to offer pull requests for line length issues or whitespace issues that are not related to indentation issues. Only changes that actually or potentially impact functionality will considered. That should bring that 2188 down to a more reasonable level! Thanks, KevinH Quote:
Last edited by KevinH; 10-16-2014 at 08:08 AM. |
|
![]() |
![]() |
![]() |
#1061 | |
but forgot what it's like
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 741
Karma: 2345678
Join Date: Dec 2011
Location: north (by northwest)
Device: Kindle Touch
|
Quote:
There is also another point wrt flake8. Given openness for contribution, is it a reasonable goal to have automated style check for keeping (enforcing) style consistency? If so, flake8 can help with it. flake8 is just a wrapper for pep8, pyflakes and McCabe tools (with McCabe deactivated by default). flake8 (pep8) tool policy could be changed to the limit (flake8 configuration) with per-project settings file (which could be commited to repository). For example, maximum line length (checked by pep8 tool) could be increased to 119 characters (as in Django coding style, to align with width of GitHub code review) or any other arbitrary but fixed value. pep8 errors reporting could be disabled either globally (with settings file, by whitelisting or blacklisting several errors) or locally (with special comment after line where error reporting should be disabled, but only for some selected errors). flake8 will also not check files with # flake8: noqa comment. Providing different flake8 settings for checking Python2/Python3 code could be automated with tox. tox is useful anyway for making things run against different Python versions in testing purposes. I'm not trying to set any priority for using flake8. It was just a small tour into its configurability. |
|
![]() |
![]() |
![]() |
#1062 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,373
Karma: 27230406
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
@KevinH: Just FYI, here is my configuration for pep8 that eliminates all the coding style warnings that I find silly/counterproductive,
https://github.com/kovidgoyal/calibr...ster/setup.cfg |
![]() |
![]() |
![]() |
#1063 | |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,788
Karma: 6000000
Join Date: Nov 2009
Device: many
|
Hi Kovid,
Thanks! By my rough estimate based on the stats run posted earlier, using your config will remove over 2100 of the "errors" from the 2188 listed. Running reindent.py should also account for the some of the others. That will leave me with a manageable 50 or so to take a closer look at. That is doable. I will commit your setup.cfg to KindleUnpack just to help us focus in on what might be real problems. Thanks also to eureka for explaining that many of these can be turned off. Take care, KevinH Quote:
|
|
![]() |
![]() |
![]() |
#1064 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,373
Karma: 27230406
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
You might find the autopep8 tool useful to easily take care of the rest. Here is a script that I use to integrate it with vim. It is used to automatically fix pep8 warnings in the current file being edited. It reads setup.cfg and tells autopep8 to ignore those classes of warnings.
Code:
#!/usr/bin/env python2 # vim:fileencoding=utf-8 from __future__ import (unicode_literals, division, absolute_import, print_function) __license__ = 'GPL v3' __copyright__ = '2013, Kovid Goyal' import sys import os import subprocess from ConfigParser import SafeConfigParser arg = sys.argv[-1] args = [] # Look for setup.cfg parent = arg while parent and os.path.dirname(parent) != parent: parent = os.path.dirname(parent) cfg = os.path.join(parent, 'setup.cfg') if os.path.exists(cfg): c = SafeConfigParser() c.read(cfg) if c.has_section('flake8'): if c.has_option('flake8', 'select'): args.append('--select=' + c.get('flake8', 'select')) if c.has_option('flake8', 'ignore'): args.append('--ignore=' + c.get('flake8', 'ignore')) if c.has_option('flake8', 'max-line-length'): args.append('--max-line-length=' + c.get('flake8', 'max-line-length')) break cmd = ['autopep8'] + args if '--as-filter' in sys.argv: raw = sys.stdin.read() p = subprocess.Popen( cmd + ['-'], stdin=subprocess.PIPE, stdout=subprocess.PIPE) stdout = p.communicate(raw)[0] rc = p.wait() if rc != 0: stdout = raw sys.stdout.write(stdout) raise SystemExit(rc) cmd += [arg] print (' '.join(cmd)) raise SystemExit(subprocess.Popen(cmd).wait()) Last edited by kovidgoyal; 10-16-2014 at 11:49 AM. |
![]() |
![]() |
![]() |
#1065 |
KCC Co-Author
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 845
Karma: 765434
Join Date: Mar 2013
Location: Poland
Device: Kindle Oasis 2
|
Well... I consider many coding standards used here as messy but this is not my project so I will just shut up and and focus on making this code work on both Python versions.
Edit: Not bad. CLI version look good. I presume that not converted prints was caused by fact that you not touched GUI part yet. I hate Tk so no help from me there. Sorry. One small trap: unescape function used in mobi_opf.py will be removed in Python 3.5. Last edited by AcidWeb; 10-16-2014 at 01:44 PM. |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Can i rotate text and insert images in Mobi and EPUB? | JanGLi | Kindle Formats | 5 | 02-02-2013 04:16 PM |
PDF to Mobi with text and images | pocketsprocket | Kindle Formats | 7 | 05-21-2012 07:06 AM |
Mobi files - images | DWC | Introduce Yourself | 5 | 07-06-2011 01:43 AM |
pdf to mobi... creating images rather than text | Dumhed | Calibre | 5 | 11-06-2010 12:08 PM |
Transfer of images on text files | anirudh215 | 2 | 06-22-2009 09:28 AM |