vitae 1.1.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- vitae-1.1.4/LICENSE +29 -0
- vitae-1.1.4/PKG-INFO +198 -0
- vitae-1.1.4/setup.cfg +18 -0
- vitae-1.1.4/setup.py +43 -0
- vitae-1.1.4/vitae/__init__.py +26 -0
- vitae-1.1.4/vitae/vitae.py +533 -0
- vitae-1.1.4/vitae.egg-info/PKG-INFO +198 -0
- vitae-1.1.4/vitae.egg-info/SOURCES.txt +10 -0
- vitae-1.1.4/vitae.egg-info/dependency_links.txt +1 -0
- vitae-1.1.4/vitae.egg-info/requires.txt +2 -0
- vitae-1.1.4/vitae.egg-info/top_level.txt +1 -0
vitae-1.1.4/LICENSE
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019, Joseph C. Slater
|
|
4
|
+
All rights reserved.
|
|
5
|
+
|
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
|
8
|
+
|
|
9
|
+
* Redistributions of source code must retain the above copyright notice, this
|
|
10
|
+
list of conditions and the following disclaimer.
|
|
11
|
+
|
|
12
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
|
14
|
+
and/or other materials provided with the distribution.
|
|
15
|
+
|
|
16
|
+
* Neither the name of the copyright holder nor the names of its
|
|
17
|
+
contributors may be used to endorse or promote products derived from
|
|
18
|
+
this software without specific prior written permission.
|
|
19
|
+
|
|
20
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
21
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
22
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
23
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
24
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
25
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
26
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
27
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
28
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
vitae-1.1.4/PKG-INFO
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: vitae
|
|
3
|
+
Version: 1.1.4
|
|
4
|
+
Summary: Tools for academics for building a Curriculum Vitae and other oft-requested documents.
|
|
5
|
+
Home-page: https://github.com/josephcslater/vitae
|
|
6
|
+
Author: Joseph C. Slater
|
|
7
|
+
Author-email: joseph.c.slater@gmail.com
|
|
8
|
+
License: UNKNOWN
|
|
9
|
+
Keywords: curriculum vitae,academia,cv,resume
|
|
10
|
+
Platform: UNKNOWN
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
.. image:: http://pepy.tech/badge/vitae
|
|
15
|
+
:target: http://pepy.tech/project/vitae
|
|
16
|
+
:alt: PyPi Download stats
|
|
17
|
+
|
|
18
|
+
vitae
|
|
19
|
+
=====
|
|
20
|
+
|
|
21
|
+
A Python module for building curriculum vitae and other documents from a ``BibTeX`` file. ``vitae`` leverages bibtexparser_, `LaTeX`_, and pandoc_ to streamline getting citations of your papers into the formats you need quickly without manual intervention. Of course, with many settings, it can be a bit tedious. I personally recommend setting up a Jupyter_ notebook with the commands you regularly execute available there. Alternatively, you can call it from the terminal which allows it to work inside a more complex workflow.
|
|
22
|
+
|
|
23
|
+
Purpose
|
|
24
|
+
-------
|
|
25
|
+
|
|
26
|
+
I hate formatting citations. It's tedious, and error-prone. Further, when I build my CV, I tend to muck it up and leave something out, mis-sort it, duplicate it accidentally, etc. So, I need a tool to do a better job with what is a menial task.
|
|
27
|
+
|
|
28
|
+
Install
|
|
29
|
+
-------
|
|
30
|
+
|
|
31
|
+
.. code::
|
|
32
|
+
|
|
33
|
+
pip install vitae
|
|
34
|
+
|
|
35
|
+
or
|
|
36
|
+
|
|
37
|
+
.. code::
|
|
38
|
+
|
|
39
|
+
pip install --user vitae
|
|
40
|
+
|
|
41
|
+
Usage
|
|
42
|
+
-----
|
|
43
|
+
|
|
44
|
+
Please see the brief `demo Jupyter notebook`_. It's very brief. I need to add more. The whole package is basically two functions. Please read the help:
|
|
45
|
+
|
|
46
|
+
``makemycv``
|
|
47
|
+
~~~~~~~~~~~~
|
|
48
|
+
|
|
49
|
+
To do anything useful here, you must have `LaTeX`_ with BibTeX installed. If you don't use `LaTeX`_, this module isn't the place to start. Sorry.
|
|
50
|
+
|
|
51
|
+
The first function here, ``makemycv``, will take a few arguments and put sorted ``\bibentry`` commands into ``.tex`` files with names corresponding to `BibTeX entry <https://en.wikibooks.org/wiki/LaTeX/Bibliography_Management#BibTeX>`_ types. In doing so, you can then simply use an ``\input`` command to embed all of these citations right in your document in an enumerated environment.
|
|
52
|
+
|
|
53
|
+
You'll need the following in the header of your LaTeX cv file.
|
|
54
|
+
|
|
55
|
+
.. code::
|
|
56
|
+
|
|
57
|
+
\usepackage{bibentry}
|
|
58
|
+
\newcommand{\enquote}[1]{``#1''}
|
|
59
|
+
\makeatletter\let\saved@bibitem\@bibitem\makeatother
|
|
60
|
+
\usepackage[colorlinks=true]{hyperref}
|
|
61
|
+
\makeatletter\let\@bibitem\saved@bibitem\makeatother
|
|
62
|
+
|
|
63
|
+
The last 3 lines are only necessary if you want to use the ``hyperref`` package, which has some compatibility issues with bibentry.
|
|
64
|
+
|
|
65
|
+
Then put:
|
|
66
|
+
|
|
67
|
+
.. code::
|
|
68
|
+
|
|
69
|
+
\input{articles.tex}
|
|
70
|
+
|
|
71
|
+
where you want articles listed, etc.
|
|
72
|
+
|
|
73
|
+
Then, with your maintained `.bib` file, in the same location as your cv (for now), and **within the same directory as your cv and cv.bib file** open a python terminal and type.
|
|
74
|
+
|
|
75
|
+
.. code::
|
|
76
|
+
|
|
77
|
+
>>> import vitae
|
|
78
|
+
>>> vitae.makemycv()
|
|
79
|
+
|
|
80
|
+
Alternatively, you can type::
|
|
81
|
+
|
|
82
|
+
> python -c "import vitae; vitae.makemycv()"
|
|
83
|
+
|
|
84
|
+
in your terminal (Anaconda Terminal if you are using Anaconda Python on Windows).
|
|
85
|
+
|
|
86
|
+
This will make your ``article.tex`` file along with the other defaults (see the help on ``makemycv``).
|
|
87
|
+
|
|
88
|
+
Note that that are a ton of options for ``makemycv``. Please use::
|
|
89
|
+
|
|
90
|
+
>>> import vitae
|
|
91
|
+
>>> help(vitae.makemycv)
|
|
92
|
+
|
|
93
|
+
To see how to tweak it to your needs.
|
|
94
|
+
|
|
95
|
+
If you try ``vitae``, please understand:
|
|
96
|
+
|
|
97
|
+
a. No warrantee. This is still a work in progress.
|
|
98
|
+
b. Please provide your feedback.
|
|
99
|
+
c. Please help! I can use help with additional portions.
|
|
100
|
+
|
|
101
|
+
If you don't use LaTeX, this isn't easy enough for you yet. It's a long ways away. However, texblog_ has a decent start in writing a `Résumé in LaTeX`_ . It *doesn't* include the paper inclusion trick being used by ``vitae``.
|
|
102
|
+
|
|
103
|
+
``write_bibs``
|
|
104
|
+
~~~~~~~~~~~~~~
|
|
105
|
+
|
|
106
|
+
The second function is ``write_bibs``. This allows you to convert bibs with a bunch of constraints into a format that pandoc_ can output. It REQUIRES a full `LaTeX`_ and pandoc_ installation that works in your terminal environment.
|
|
107
|
+
|
|
108
|
+
Constraints include:
|
|
109
|
+
|
|
110
|
+
1. Since a year
|
|
111
|
+
2. Number
|
|
112
|
+
3. Types of publications
|
|
113
|
+
|
|
114
|
+
For instance:
|
|
115
|
+
|
|
116
|
+
.. code::
|
|
117
|
+
|
|
118
|
+
>>> import vitae
|
|
119
|
+
>>> vitae.write_bibs(bibfile = '/Users/jslater/Documents/Resumes/cv.bib',
|
|
120
|
+
bibliographystyle='aiaa',
|
|
121
|
+
outfile_name='try.html',
|
|
122
|
+
since_year=2008)
|
|
123
|
+
|
|
124
|
+
Alternatively, from a command line::
|
|
125
|
+
|
|
126
|
+
> python -c "import vitae; vitae.write_bibs(bibfile='cv.bib',
|
|
127
|
+
bibliographystyle='aiaa',
|
|
128
|
+
outfile_name = 'bibs.html',
|
|
129
|
+
since_year=2008)"
|
|
130
|
+
|
|
131
|
+
How I use it
|
|
132
|
+
------------
|
|
133
|
+
|
|
134
|
+
I have a Makefile that I use for tasks that I am creating. The first is a simple one for building my cv, the contents of which are::
|
|
135
|
+
|
|
136
|
+
help:
|
|
137
|
+
@echo "Please use \`make <target>' where <target> is one of"
|
|
138
|
+
@echo " cv to make standard pdf cv"
|
|
139
|
+
@echo " pdf see cv"
|
|
140
|
+
|
|
141
|
+
cv:
|
|
142
|
+
python -c 'import vitae; vitae.makemycv(silent = True)'
|
|
143
|
+
pdflatex cv
|
|
144
|
+
bibtex cv
|
|
145
|
+
pdflatex cv
|
|
146
|
+
|
|
147
|
+
pdf:
|
|
148
|
+
cv
|
|
149
|
+
|
|
150
|
+
Summary
|
|
151
|
+
-------
|
|
152
|
+
Please see the full help on each function.
|
|
153
|
+
|
|
154
|
+
Vitae is on pypi_ but you can pip install the latest, and possibly non-working, version right now from github (I love bug reports!):
|
|
155
|
+
|
|
156
|
+
.. code::
|
|
157
|
+
|
|
158
|
+
pip install git+https://github.com/josephcslater/vitae
|
|
159
|
+
|
|
160
|
+
Help
|
|
161
|
+
----
|
|
162
|
+
``vitae`` uses luatex_ to enable unicode characters. On Ubuntu, the base tetex install doesn't include the necessary file ``luaotfload``. To resolve this open a terminal and type::
|
|
163
|
+
|
|
164
|
+
sudo apt install texlive-luatex
|
|
165
|
+
|
|
166
|
+
Release notes:
|
|
167
|
+
--------------
|
|
168
|
+
|
|
169
|
+
See the CHANGELOG_ for the full history of releases.
|
|
170
|
+
|
|
171
|
+
Future plans
|
|
172
|
+
------------
|
|
173
|
+
|
|
174
|
+
1. Preferences.
|
|
175
|
+
|
|
176
|
+
a. Reader (doesn't overwrite specified arguments)
|
|
177
|
+
|
|
178
|
+
b. Writer (configurator on call or when it doesn't exist)
|
|
179
|
+
|
|
180
|
+
c. Editor?
|
|
181
|
+
|
|
182
|
+
2. Bug fixes when I find them. Any other suggestions?
|
|
183
|
+
|
|
184
|
+
What else would be nice?
|
|
185
|
+
|
|
186
|
+
.. _CHANGELOG: https://github.com/josephcslater/vitae/blob/master/CHANGELOG.rst
|
|
187
|
+
.. _pandoc: http://pandoc.org
|
|
188
|
+
.. _luatex: http://www.luatex.org
|
|
189
|
+
.. _texblog: https://texblog.org
|
|
190
|
+
.. _`Résumé in LaTeX`: https://texblog.org/2012/04/25/writing-a-cv-in-latex/
|
|
191
|
+
.. _`LaTeX`: https://www.latex-tutorial.com/installation/
|
|
192
|
+
.. _bibtexparser: https://bibtexparser.readthedocs.io/en/master/
|
|
193
|
+
.. _Jupyter: https://www.Jupyter.org
|
|
194
|
+
.. _Makefile: https://www.gnu.org/software/make/manual/html_node/Introduction.html
|
|
195
|
+
.. _`demo Jupyter notebook`: https://github.com/josephcslater/vitae/blob/master/Vitae.ipynb
|
|
196
|
+
.. _pypi: https://pypi.org/project/vitae/
|
|
197
|
+
|
|
198
|
+
|
vitae-1.1.4/setup.cfg
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
[metadata]
|
|
2
|
+
description-file = readme.rst
|
|
3
|
+
|
|
4
|
+
[build_sphinx]
|
|
5
|
+
source-dir = docs
|
|
6
|
+
build-dir = docs/build
|
|
7
|
+
all_files = 1
|
|
8
|
+
|
|
9
|
+
[upload_sphinx]
|
|
10
|
+
upload-dir = docs/build/html
|
|
11
|
+
|
|
12
|
+
[bdist_wheel]
|
|
13
|
+
python-tag = py35
|
|
14
|
+
|
|
15
|
+
[egg_info]
|
|
16
|
+
tag_build =
|
|
17
|
+
tag_date = 0
|
|
18
|
+
|
vitae-1.1.4/setup.py
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
|
|
3
|
+
#from distutils.core import setup
|
|
4
|
+
from setuptools import setup
|
|
5
|
+
import os
|
|
6
|
+
import sys
|
|
7
|
+
|
|
8
|
+
if sys.version_info < (3, 5):
|
|
9
|
+
sys.exit('Sorry, Python < 3.5 is not supported.')
|
|
10
|
+
# Utility function to read the README file.
|
|
11
|
+
# Used for the long_description. It's nice, because now 1) we have a top level
|
|
12
|
+
# README file and 2) it's easier to type in the README file than to put a raw
|
|
13
|
+
# string in below ...
|
|
14
|
+
def read(fname):
|
|
15
|
+
return open(os.path.join(os.path.dirname(__file__), fname)).read()
|
|
16
|
+
|
|
17
|
+
with open('vitae/__init__.py', 'rb') as fid:
|
|
18
|
+
for line in fid:
|
|
19
|
+
line = line.decode('utf-8')
|
|
20
|
+
if line.startswith('__version__'):
|
|
21
|
+
version = line.strip().split()[-1][1:-1]
|
|
22
|
+
break
|
|
23
|
+
|
|
24
|
+
download_url = ('https://github.com/josephcslater/vitae/\
|
|
25
|
+
blob/master/dist/vitae-' + version + '.whl')
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
setup(name='vitae',
|
|
29
|
+
version=version,
|
|
30
|
+
description=('Tools for academics for building a Curriculum Vitae and other oft-requested documents.'),
|
|
31
|
+
author=u'Joseph C. Slater',
|
|
32
|
+
author_email='joseph.c.slater@gmail.com',
|
|
33
|
+
url='https://github.com/josephcslater/vitae',
|
|
34
|
+
packages=['vitae'],
|
|
35
|
+
package_data={'vitae': ['../readme.rst', 'data/*.bib'],
|
|
36
|
+
'': ['readme.rst']},
|
|
37
|
+
long_description=read('readme.rst'),
|
|
38
|
+
keywords=['curriculum vitae', 'academia', 'cv', 'resume'],
|
|
39
|
+
install_requires=['bibtexparser', 'appdirs'],
|
|
40
|
+
include_package_data=True
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
# https://docs.python.org/3/distutils/setupscript.html#additional-meta-data
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from .vitae import *
|
|
2
|
+
|
|
3
|
+
"""Vitae
|
|
4
|
+
|
|
5
|
+
A set of tools for academics regularly needing updated CVs.
|
|
6
|
+
Joseph C. Slater
|
|
7
|
+
|
|
8
|
+
`import vitae`
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
__title__ = 'vitae'
|
|
12
|
+
__version__ = '1.1.4'
|
|
13
|
+
__author__ = u'Joseph C. Slater'
|
|
14
|
+
__license__ = 'BSD3'
|
|
15
|
+
__copyright__ = 'Copyright 2018 Joseph C. Slater'
|
|
16
|
+
__all__ = ['vitae',
|
|
17
|
+
'__version__']
|
|
18
|
+
|
|
19
|
+
"""
|
|
20
|
+
If the __all__ above is commented out, this code will then execute to
|
|
21
|
+
completion, as the default behaviour of import * is to import all symbols
|
|
22
|
+
that do not begin with an underscore, from the given namespace.
|
|
23
|
+
|
|
24
|
+
Reference:
|
|
25
|
+
https://docs.python.org/3.5/tutorial/modules.html#importing-from-a-package
|
|
26
|
+
"""
|
|
@@ -0,0 +1,533 @@
|
|
|
1
|
+
"""Create citation files from a bib file."""
|
|
2
|
+
|
|
3
|
+
import bibtexparser
|
|
4
|
+
import subprocess
|
|
5
|
+
import tempfile
|
|
6
|
+
from bibtexparser.bparser import BibTexParser
|
|
7
|
+
from bibtexparser.customization import homogenize_latex_encoding
|
|
8
|
+
import os
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def makemycv(filename='cv.bib',
|
|
13
|
+
silent=True,
|
|
14
|
+
bibtex_types=('inbook', 'article', 'periodical',
|
|
15
|
+
'techreport', 'inproceedings'),
|
|
16
|
+
writeout=True,
|
|
17
|
+
indent=' ',
|
|
18
|
+
author=None,
|
|
19
|
+
outpath=None,
|
|
20
|
+
entrytypes=None):
|
|
21
|
+
r"""Create sub-bib TeX files for including into CV.abs
|
|
22
|
+
|
|
23
|
+
Written files with be names `entrytype```.tex`` to the current directory
|
|
24
|
+
if `outpath` is not defined. The files `entrytype```.tex`` will overwrite
|
|
25
|
+
files with the same name **without warning**.
|
|
26
|
+
|
|
27
|
+
Parameters
|
|
28
|
+
----------
|
|
29
|
+
filename : string (optional: default cv.tex)
|
|
30
|
+
Name (including optional path) of bib file containing citation entries
|
|
31
|
+
bibtex_types : tuple of strings (optional)
|
|
32
|
+
List of bibtex bibtex_types to generate \bibentry .tex files for.
|
|
33
|
+
Files will be be named `entrytype```.tex``
|
|
34
|
+
writeout : boolean (optional: default True)
|
|
35
|
+
Write to files. If false, only write to screenself.
|
|
36
|
+
indent : string
|
|
37
|
+
string of spaces for prettying up the item lists
|
|
38
|
+
author : string
|
|
39
|
+
select authors whose entries should be included.
|
|
40
|
+
outpath : string
|
|
41
|
+
output path to write files to.
|
|
42
|
+
silent : boolean (optional: default True)
|
|
43
|
+
print results to screen
|
|
44
|
+
|
|
45
|
+
Returns
|
|
46
|
+
-------
|
|
47
|
+
results : strings
|
|
48
|
+
Content(s) of each .tex file generated- in case you want them.
|
|
49
|
+
unaccounted : array
|
|
50
|
+
Array of bib entries not used in creation of the output.
|
|
51
|
+
bibs : array
|
|
52
|
+
Full array created by bibtexparser.
|
|
53
|
+
|
|
54
|
+
https://nwalsh.com/tex/texhelp/bibtx-7.html
|
|
55
|
+
|
|
56
|
+
Examples
|
|
57
|
+
--------
|
|
58
|
+
Makes tex files for inclusion in cv.tex (articles.tex, etc.).
|
|
59
|
+
See readme.rts on github.com
|
|
60
|
+
>>> import vitae
|
|
61
|
+
>>> vitae.makemycv(filename='cv.bib')
|
|
62
|
+
|
|
63
|
+
Alternatively from a terminal prompt:
|
|
64
|
+
> python -c "import vitae; vitae.makemycv(filename='cv.bib')"
|
|
65
|
+
|
|
66
|
+
"""
|
|
67
|
+
if entrytypes is not None:
|
|
68
|
+
print('entrytypes will be deprecated in future releases.')
|
|
69
|
+
print('Please use bibtex_types')
|
|
70
|
+
bibtex_types = entrytypes
|
|
71
|
+
|
|
72
|
+
if os.path.isfile(filename) is False:
|
|
73
|
+
print('{} is not an actual bib file.'.format(filename))
|
|
74
|
+
return
|
|
75
|
+
|
|
76
|
+
if outpath is None:
|
|
77
|
+
outpath = ''
|
|
78
|
+
|
|
79
|
+
if not os.path.isdir(outpath) and outpath != '':
|
|
80
|
+
print(outpath, ' is not a valid directory.')
|
|
81
|
+
return
|
|
82
|
+
|
|
83
|
+
parser = BibTexParser()
|
|
84
|
+
parser.customization = homogenize_latex_encoding
|
|
85
|
+
parser.ignore_nonstandard_types = False
|
|
86
|
+
|
|
87
|
+
with open(filename) as bibtex_file:
|
|
88
|
+
bib_database = bibtexparser.load(bibtex_file, parser)
|
|
89
|
+
|
|
90
|
+
bibs = bib_database.entries
|
|
91
|
+
|
|
92
|
+
if author is not None:
|
|
93
|
+
bibs = by_author(author, bibs)
|
|
94
|
+
|
|
95
|
+
results = {}
|
|
96
|
+
|
|
97
|
+
for entrytype in bibtex_types:
|
|
98
|
+
entry = [[bib['year'], bib['ID'], bib['title']]
|
|
99
|
+
for bib in bibs if bib['ENTRYTYPE'] == entrytype]
|
|
100
|
+
|
|
101
|
+
entry_sorted = sorted(entry, key=lambda paper: paper[0], reverse=True)
|
|
102
|
+
|
|
103
|
+
if silent is False:
|
|
104
|
+
if entrytype[-1] == 's':
|
|
105
|
+
print('Number of {} is {}'.format(
|
|
106
|
+
entrytype, len(entry_sorted)))
|
|
107
|
+
else:
|
|
108
|
+
print('Number of {}s is {}'.format(
|
|
109
|
+
entrytype, len(entry_sorted)))
|
|
110
|
+
|
|
111
|
+
file_contents = '\\begin{enumerate}\n'
|
|
112
|
+
for entry in entry_sorted:
|
|
113
|
+
file_contents += indent + '\\item \\bibentry{' + entry[1] + '}\n'
|
|
114
|
+
file_contents += '\\end{enumerate}'
|
|
115
|
+
if writeout is True:
|
|
116
|
+
with open(os.path.join(outpath, entrytype + '.tex'), 'w') as file:
|
|
117
|
+
file.write(file_contents)
|
|
118
|
+
else:
|
|
119
|
+
print(file_contents)
|
|
120
|
+
|
|
121
|
+
results[entrytype] = file_contents
|
|
122
|
+
|
|
123
|
+
unaccounted = [bib for bib in bibs if bib['ENTRYTYPE'] not in bibtex_types]
|
|
124
|
+
|
|
125
|
+
if silent is False:
|
|
126
|
+
print('Unaccounted for entries is {}:'.format(len(unaccounted)))
|
|
127
|
+
for bib in unaccounted:
|
|
128
|
+
print(bib['ID'],
|
|
129
|
+
'\n ', bib['year'],
|
|
130
|
+
'\n ', bib['ENTRYTYPE'],
|
|
131
|
+
'\n ', bib['title'])
|
|
132
|
+
|
|
133
|
+
return results, unaccounted, bibs
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def by_author(authorname, bibs):
|
|
137
|
+
"""Return only bibs containing authorname."""
|
|
138
|
+
keepindex = []
|
|
139
|
+
i = 0
|
|
140
|
+
|
|
141
|
+
an = authorname.replace(" ", "")
|
|
142
|
+
|
|
143
|
+
authorname = authorname.replace(',', ', ')
|
|
144
|
+
authorname = authorname.replace(" ", " ")
|
|
145
|
+
|
|
146
|
+
authorshort = 'xxxxxxx'
|
|
147
|
+
if ',' in authorname and len(an) > (1+an.find(',')):
|
|
148
|
+
authorshort = (authorname[:authorname.find(',')]
|
|
149
|
+
+ ', '
|
|
150
|
+
+ an[an.find(',')+1])
|
|
151
|
+
|
|
152
|
+
print('number of bibs', len(bibs))
|
|
153
|
+
|
|
154
|
+
for bib in bibs:
|
|
155
|
+
if 'author' in bib:
|
|
156
|
+
bibauthor = bib['author']
|
|
157
|
+
bibauthor = bibauthor.replace(',', ', ')
|
|
158
|
+
bibauthor = bibauthor.replace(' ', ' ')
|
|
159
|
+
|
|
160
|
+
if authorname in bibauthor:
|
|
161
|
+
keepindex.append(i)
|
|
162
|
+
i += 1
|
|
163
|
+
elif authorshort in bibauthor:
|
|
164
|
+
print('Close name WARNING- is bib entry correct?')
|
|
165
|
+
print(bib['author'], ': ', bib['title'])
|
|
166
|
+
author_bibs = [bibs[i] for i in keepindex]
|
|
167
|
+
return author_bibs
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
def replace_enquote(string):
|
|
171
|
+
r"""Replace \enquote with proper quotes."""
|
|
172
|
+
front = string[:string.find(r'\enquote{')]
|
|
173
|
+
back = string[string.find(r'\enquote{'):].replace('}', "''", 1)
|
|
174
|
+
back = back.replace(r'\enquote{', '``')
|
|
175
|
+
return front + back
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
def read_bbl(bblfilename):
|
|
179
|
+
"""Read bbl file and return dictionary of formatted citations."""
|
|
180
|
+
if not is_tool('pdflatex') or not is_tool('bibtex'):
|
|
181
|
+
print("Both pdflatex and bibtex must exist on your command",
|
|
182
|
+
" line to use this function.")
|
|
183
|
+
return
|
|
184
|
+
|
|
185
|
+
isbibtext = 0
|
|
186
|
+
formattedbibs = {}
|
|
187
|
+
# print(bibtexparser)
|
|
188
|
+
bbl = open(bblfilename, "r")
|
|
189
|
+
for line in bbl:
|
|
190
|
+
if line[:6] == r'\begin' or line[:4] == r'\end':
|
|
191
|
+
pass
|
|
192
|
+
elif r'\providecommand' in line:
|
|
193
|
+
pass
|
|
194
|
+
elif r'bibitem' in line:
|
|
195
|
+
bibitem = line[line.find('{')+1: line.find('}')]
|
|
196
|
+
isbibtext = 1
|
|
197
|
+
bibtext = ''
|
|
198
|
+
elif isbibtext == 1:
|
|
199
|
+
if len(line) > 2:
|
|
200
|
+
bibtext += line.strip('\n')
|
|
201
|
+
elif len(line) < 2:
|
|
202
|
+
bibtext = replace_enquote(bibtext)
|
|
203
|
+
formattedbibs[bibitem] = bibtext
|
|
204
|
+
isbibtext = 0
|
|
205
|
+
|
|
206
|
+
return formattedbibs
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
def formatted_bibs(bibfile, bibliographystyle='plain'):
|
|
210
|
+
"""Make a dictionary of formatted bibs.
|
|
211
|
+
|
|
212
|
+
Parameters
|
|
213
|
+
----------
|
|
214
|
+
bibfile : string
|
|
215
|
+
full path and file name to the .bib file
|
|
216
|
+
bibliographystyle : string (optional)
|
|
217
|
+
bst (bib style file) to use. Default: 'plain'
|
|
218
|
+
|
|
219
|
+
Returns
|
|
220
|
+
-------
|
|
221
|
+
formattedbibs : dictionary of strings
|
|
222
|
+
dictionary of formatted citations with Cite keys as keys.
|
|
223
|
+
bibs : array
|
|
224
|
+
bibfile array from bibtexparser
|
|
225
|
+
|
|
226
|
+
"""
|
|
227
|
+
# path = os.path.dirname(bibfile)
|
|
228
|
+
# bibfilename = os.path.basename(bibfile)
|
|
229
|
+
|
|
230
|
+
bibliographystyle = bibliographystyle.replace('.bst', '')
|
|
231
|
+
old_directory = os.getcwd()
|
|
232
|
+
|
|
233
|
+
with tempfile.TemporaryDirectory() as tmpdirname:
|
|
234
|
+
os.chdir(tmpdirname)
|
|
235
|
+
with open('cv_temp.tex', 'w') as template:
|
|
236
|
+
# template.write('hello')
|
|
237
|
+
template_head = (r"""% !TEX root = cv.tex
|
|
238
|
+
\documentclass[12pt, letter]{article}
|
|
239
|
+
\usepackage[utf8]{inputenc}
|
|
240
|
+
\usepackage[T1]{fontenc}
|
|
241
|
+
\usepackage{bibentry}
|
|
242
|
+
\newcommand{\enquote}[1]{``#1''}
|
|
243
|
+
\makeatletter\let\saved@bibitem\@bibitem\makeatother
|
|
244
|
+
\usepackage[colorlinks=true]{hyperref}
|
|
245
|
+
\makeatletter\let\@bibitem\saved@bibitem\makeatother
|
|
246
|
+
\usepackage{url}{}
|
|
247
|
+
\renewcommand{\cite}{\bibentry}
|
|
248
|
+
\begin{document}
|
|
249
|
+
\nobibliography{"""
|
|
250
|
+
+ bibfile
|
|
251
|
+
+ r"""}
|
|
252
|
+
\bibliographystyle{"""
|
|
253
|
+
+ bibliographystyle
|
|
254
|
+
+ r"""}
|
|
255
|
+
\pagestyle{plain}
|
|
256
|
+
\input{article.tex}
|
|
257
|
+
\input{inbook.tex}
|
|
258
|
+
\input{inproceedings}
|
|
259
|
+
\input{periodical}
|
|
260
|
+
\input{techreport}
|
|
261
|
+
\end{document}""")
|
|
262
|
+
template.write(template_head)
|
|
263
|
+
_, _, bibs = makemycv(filename=bibfile, silent=True)
|
|
264
|
+
|
|
265
|
+
lualatex_result = subprocess.run(
|
|
266
|
+
['lualatex', '-interaction=batchmode', 'cv_temp'])
|
|
267
|
+
if lualatex_result.returncode != 0:
|
|
268
|
+
print('lualatex failed to compile cv_temp.tex. '
|
|
269
|
+
'Check the log for details.')
|
|
270
|
+
|
|
271
|
+
bibtex_result = subprocess.run(['bibtex', 'cv_temp'])
|
|
272
|
+
if bibtex_result.returncode != 0:
|
|
273
|
+
print('bibtex failed to process cv_temp.aux. '
|
|
274
|
+
'Check the log for details.')
|
|
275
|
+
|
|
276
|
+
# print(os.path.join(tmpdirname, 'cv_temp.bbl'))
|
|
277
|
+
formattedbibs = read_bbl('cv_temp.bbl')
|
|
278
|
+
|
|
279
|
+
os.chdir(old_directory) # Unnecessary
|
|
280
|
+
return formattedbibs, bibs
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
def is_tool(name):
|
|
284
|
+
"""Check whether `name` is on PATH and marked as executable."""
|
|
285
|
+
from shutil import which
|
|
286
|
+
return which(name) is not None
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
def merge_formatted_into_db(formattedbibs, bibfilename=None, bibs=None):
|
|
290
|
+
"""Create bib database including formated bibs."""
|
|
291
|
+
print('formattedbibs length', len(formattedbibs))
|
|
292
|
+
if bibs is None:
|
|
293
|
+
if bibfilename is None:
|
|
294
|
+
print('No bib file name given.')
|
|
295
|
+
return
|
|
296
|
+
|
|
297
|
+
if os.path.isfile(bibfilename) is False or 'bib' not in bibfilename:
|
|
298
|
+
print('{} is not an actual bib file.')
|
|
299
|
+
return
|
|
300
|
+
|
|
301
|
+
parser = BibTexParser()
|
|
302
|
+
parser.customization = homogenize_latex_encoding
|
|
303
|
+
parser.ignore_nonstandard_types = False
|
|
304
|
+
|
|
305
|
+
with open(bibfilename) as bibtex_file:
|
|
306
|
+
bib_database = bibtexparser.load(bibtex_file, parser, encoding='utf-8')
|
|
307
|
+
|
|
308
|
+
bibs = bib_database.entries
|
|
309
|
+
|
|
310
|
+
bib_database = [[bib['year'],
|
|
311
|
+
bib['ID'],
|
|
312
|
+
bib['title'],
|
|
313
|
+
bib['ENTRYTYPE'],
|
|
314
|
+
formattedbibs[bib['ID']]]
|
|
315
|
+
for bib in bibs if bib['ID'] in formattedbibs.keys()]
|
|
316
|
+
print('bib_database formatted', len(bib_database))
|
|
317
|
+
return bib_database
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
def write_bibs(bibfile=None,
|
|
321
|
+
bibliographystyle='plain',
|
|
322
|
+
outfile_name=None,
|
|
323
|
+
since_year=None,
|
|
324
|
+
number_citations=None,
|
|
325
|
+
bibtex_types=('articles',),
|
|
326
|
+
authorname=None,
|
|
327
|
+
outputformat=None,
|
|
328
|
+
silent=False,
|
|
329
|
+
standalone=True,
|
|
330
|
+
overwrite=False):
|
|
331
|
+
"""Write formatted bibs from bibfile to desired format.
|
|
332
|
+
|
|
333
|
+
Parameters
|
|
334
|
+
----------
|
|
335
|
+
bibfile : string
|
|
336
|
+
full path and file name to the .bib file
|
|
337
|
+
bibliographystyle : string (optional)
|
|
338
|
+
bst (bib style file) to use. Default: 'plain'.
|
|
339
|
+
outfile_name : string (optional)
|
|
340
|
+
name of output file. Default bibfile name with .tex extension. Default
|
|
341
|
+
output format is html.
|
|
342
|
+
since_year : integer (optional)
|
|
343
|
+
year of oldest citation to include. Default: All years.
|
|
344
|
+
number_citations : integer (optional)
|
|
345
|
+
maximum number of citations to include. Default: all.
|
|
346
|
+
bibtex_types : tuple of strings (optional)
|
|
347
|
+
list of types of entries to include. Default: ('articles')
|
|
348
|
+
authorname : string (optional)
|
|
349
|
+
author whos papers to include. Default: all.
|
|
350
|
+
silent : Boolean (optional)
|
|
351
|
+
display diagnostics. Default: False (will display diagnostics)
|
|
352
|
+
standalone : Boolean (optional)
|
|
353
|
+
By default, pandoc generates only a fragment. If you want a full
|
|
354
|
+
document set this to False. Default: True
|
|
355
|
+
overwrite : Boolean (optional)
|
|
356
|
+
Overwrite results files? Default: False
|
|
357
|
+
|
|
358
|
+
Examples
|
|
359
|
+
--------
|
|
360
|
+
To write citations to an html file:
|
|
361
|
+
>>> import vitae
|
|
362
|
+
>>> vitae.write_bibs(bibfile = '/Users/jslater/Documents/Resumes/cv.bib',
|
|
363
|
+
bibliographystyle='plain',
|
|
364
|
+
outfile_name='try.html',
|
|
365
|
+
since_year=2008)
|
|
366
|
+
|
|
367
|
+
Alternatively, from a terminal prompt:
|
|
368
|
+
> python -c "import vitae; vitae.write_bibs(bibfile='cv.bib',
|
|
369
|
+
bibliographystyle='plain',
|
|
370
|
+
outfile_name = 'bibs.html',
|
|
371
|
+
since_year=2008)"
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
"""
|
|
375
|
+
if '.bib' in outfile_name:
|
|
376
|
+
print('I refuse to write over a bib file. '
|
|
377
|
+
+ 'While this software comes with no warrantee, '
|
|
378
|
+
+ "I'm also not going to knowlingly cause you damage. "
|
|
379
|
+
+ 'Please choose a more sensible output file name.')
|
|
380
|
+
return
|
|
381
|
+
|
|
382
|
+
if bibfile is None:
|
|
383
|
+
print('You must include the input named argument: bibfile')
|
|
384
|
+
print('This should include with full name with path.')
|
|
385
|
+
print('If the path is not included, cwd will be presumed.')
|
|
386
|
+
print('')
|
|
387
|
+
print('On Mac or Linux, this looks like:')
|
|
388
|
+
print('\'/Users/myusername/Documents/CVs/cv.bib\'')
|
|
389
|
+
print('')
|
|
390
|
+
print('On Windows, this looks like:')
|
|
391
|
+
print('r\'C:\\Users\\myusername\\Documents\\CVs\\cv.bib\'')
|
|
392
|
+
print('NOTE: The \'r\' may be necessary on Windows so that '
|
|
393
|
+
+ '\'\\\' is not treated as an escape character.')
|
|
394
|
+
return
|
|
395
|
+
|
|
396
|
+
if os.path.isfile(bibfile) is False:
|
|
397
|
+
print(bibfile, ' cannot be found at that location.')
|
|
398
|
+
print('Please check path and try again.')
|
|
399
|
+
return
|
|
400
|
+
|
|
401
|
+
if (not is_tool('pdflatex')
|
|
402
|
+
or not is_tool('bibtex')
|
|
403
|
+
or not is_tool('pandoc')):
|
|
404
|
+
|
|
405
|
+
print("pdflatex, bibtex and pandoc must exist on your command",
|
|
406
|
+
" line to use this function.\n")
|
|
407
|
+
print("Please see the documentation at:")
|
|
408
|
+
print(r"https://github.com/josephcslater/vitae")
|
|
409
|
+
return
|
|
410
|
+
|
|
411
|
+
path = os.path.dirname(bibfile)
|
|
412
|
+
|
|
413
|
+
if path == '':
|
|
414
|
+
path = os.getcwd()
|
|
415
|
+
bibfile = os.path.join(path, bibfile)
|
|
416
|
+
|
|
417
|
+
bibfilename = os.path.basename(bibfile)
|
|
418
|
+
bibfilenameroot = bibfilename[:-4]
|
|
419
|
+
|
|
420
|
+
# No output file specified
|
|
421
|
+
if outfile_name is None:
|
|
422
|
+
outfile_name = bibfilenameroot + '.html'
|
|
423
|
+
outfile_name = os.path.join(path, outfile_name)
|
|
424
|
+
|
|
425
|
+
if os.path.dirname(outfile_name) == '':
|
|
426
|
+
path_output = path
|
|
427
|
+
else:
|
|
428
|
+
path_output = os.path.dirname(outfile_name)
|
|
429
|
+
|
|
430
|
+
if not os.path.isdir(path_output) and path_output != '':
|
|
431
|
+
print('Specified output path:')
|
|
432
|
+
print(path_output)
|
|
433
|
+
print('is not a valid path. Please play again.')
|
|
434
|
+
return
|
|
435
|
+
|
|
436
|
+
filename_output = os.path.basename(outfile_name)
|
|
437
|
+
|
|
438
|
+
root_output = filename_output
|
|
439
|
+
|
|
440
|
+
if '.' in filename_output:
|
|
441
|
+
root_output = filename_output[:filename_output.find('.')]
|
|
442
|
+
|
|
443
|
+
print(root_output)
|
|
444
|
+
|
|
445
|
+
# Format the bibs. We just format every one in the file, then use what we
|
|
446
|
+
# must later.
|
|
447
|
+
formattedbibs, bibs = formatted_bibs(bibfile,
|
|
448
|
+
bibliographystyle=bibliographystyle)
|
|
449
|
+
|
|
450
|
+
print('result of formatting bibs', len(formattedbibs))
|
|
451
|
+
bibs = merge_formatted_into_db(formattedbibs, bibs=bibs)
|
|
452
|
+
|
|
453
|
+
# Keep only bibs by chosen author.
|
|
454
|
+
if authorname is not None:
|
|
455
|
+
bibs = by_author(authorname, bibs)
|
|
456
|
+
|
|
457
|
+
# At this point, we have a bibs database with just bibs by authorname
|
|
458
|
+
# Next steps:
|
|
459
|
+
|
|
460
|
+
# 3. Truncate non-desired bibtex_types
|
|
461
|
+
bibs = [bib for bib in bibs if bib[3] in bibtex_types]
|
|
462
|
+
|
|
463
|
+
# Sort by date
|
|
464
|
+
bibs_sorted = sorted(bibs, key=lambda paper: paper[0], reverse=True)
|
|
465
|
+
|
|
466
|
+
# 2. Truncate older articles
|
|
467
|
+
if since_year is not None:
|
|
468
|
+
bibs_truncated = [bib for bib in bibs_sorted
|
|
469
|
+
if int(bib[0]) >= since_year]
|
|
470
|
+
else:
|
|
471
|
+
bibs_truncated = bibs_sorted
|
|
472
|
+
|
|
473
|
+
# 4. Truncate beyond numberself.
|
|
474
|
+
|
|
475
|
+
if number_citations is not None and number_citations < len(bibs_truncated):
|
|
476
|
+
bibs_final = bibs_truncated[:number_citations]
|
|
477
|
+
else:
|
|
478
|
+
bibs_final = bibs_truncated
|
|
479
|
+
|
|
480
|
+
cwd = os.getcwd()
|
|
481
|
+
|
|
482
|
+
os.chdir(path_output)
|
|
483
|
+
|
|
484
|
+
outfile_name_tex = root_output + '.tex'
|
|
485
|
+
|
|
486
|
+
if os.path.isfile(outfile_name_tex) and not overwrite:
|
|
487
|
+
os.rename(outfile_name_tex, outfile_name_tex[:-4]+'_old.tex')
|
|
488
|
+
|
|
489
|
+
# routine to write out bibs_final bibsfinalfilename
|
|
490
|
+
with open(outfile_name_tex, 'w') as filename:
|
|
491
|
+
for bib in bibs_final:
|
|
492
|
+
filename.write(bib[4])
|
|
493
|
+
filename.write('\n')
|
|
494
|
+
filename.write('\n')
|
|
495
|
+
|
|
496
|
+
with open(outfile_name_tex) as f:
|
|
497
|
+
newText = f.read().replace('{\\em', '\\emph{')
|
|
498
|
+
|
|
499
|
+
with open(outfile_name_tex, "w") as f:
|
|
500
|
+
f.write(newText)
|
|
501
|
+
|
|
502
|
+
# Store old version of formatted references.
|
|
503
|
+
if os.path.isfile(filename_output) and not overwrite:
|
|
504
|
+
print('\n\n',
|
|
505
|
+
filename_output,
|
|
506
|
+
'moved to',
|
|
507
|
+
filename_output[:filename_output.find('.')]
|
|
508
|
+
+ '_old'
|
|
509
|
+
+ filename_output[filename_output.find('.'):],
|
|
510
|
+
'\n\n')
|
|
511
|
+
os.rename(filename_output,
|
|
512
|
+
filename_output[:filename_output.find('.')]
|
|
513
|
+
+ '_old'
|
|
514
|
+
+ filename_output[filename_output.find('.'):])
|
|
515
|
+
|
|
516
|
+
pandoc_args = []
|
|
517
|
+
|
|
518
|
+
if standalone:
|
|
519
|
+
pandoc_args = ['-s', '-V', 'pagetitle:My Bibs', '-V', 'title:My Bibs']
|
|
520
|
+
|
|
521
|
+
pandoc_command = (['pandoc']
|
|
522
|
+
+ pandoc_args
|
|
523
|
+
+ [outfile_name_tex, '-o', filename_output])
|
|
524
|
+
|
|
525
|
+
pandoc_result = subprocess.run(pandoc_command)
|
|
526
|
+
if pandoc_result.returncode != 0:
|
|
527
|
+
print('pandoc failed to convert {} to {}.'.format(
|
|
528
|
+
outfile_name_tex, filename_output))
|
|
529
|
+
os.chdir(cwd)
|
|
530
|
+
|
|
531
|
+
|
|
532
|
+
if __name__ == '__main__':
|
|
533
|
+
print('executing from command line')
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: vitae
|
|
3
|
+
Version: 1.1.4
|
|
4
|
+
Summary: Tools for academics for building a Curriculum Vitae and other oft-requested documents.
|
|
5
|
+
Home-page: https://github.com/josephcslater/vitae
|
|
6
|
+
Author: Joseph C. Slater
|
|
7
|
+
Author-email: joseph.c.slater@gmail.com
|
|
8
|
+
License: UNKNOWN
|
|
9
|
+
Keywords: curriculum vitae,academia,cv,resume
|
|
10
|
+
Platform: UNKNOWN
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
.. image:: http://pepy.tech/badge/vitae
|
|
15
|
+
:target: http://pepy.tech/project/vitae
|
|
16
|
+
:alt: PyPi Download stats
|
|
17
|
+
|
|
18
|
+
vitae
|
|
19
|
+
=====
|
|
20
|
+
|
|
21
|
+
A Python module for building curriculum vitae and other documents from a ``BibTeX`` file. ``vitae`` leverages bibtexparser_, `LaTeX`_, and pandoc_ to streamline getting citations of your papers into the formats you need quickly without manual intervention. Of course, with many settings, it can be a bit tedious. I personally recommend setting up a Jupyter_ notebook with the commands you regularly execute available there. Alternatively, you can call it from the terminal which allows it to work inside a more complex workflow.
|
|
22
|
+
|
|
23
|
+
Purpose
|
|
24
|
+
-------
|
|
25
|
+
|
|
26
|
+
I hate formatting citations. It's tedious, and error-prone. Further, when I build my CV, I tend to muck it up and leave something out, mis-sort it, duplicate it accidentally, etc. So, I need a tool to do a better job with what is a menial task.
|
|
27
|
+
|
|
28
|
+
Install
|
|
29
|
+
-------
|
|
30
|
+
|
|
31
|
+
.. code::
|
|
32
|
+
|
|
33
|
+
pip install vitae
|
|
34
|
+
|
|
35
|
+
or
|
|
36
|
+
|
|
37
|
+
.. code::
|
|
38
|
+
|
|
39
|
+
pip install --user vitae
|
|
40
|
+
|
|
41
|
+
Usage
|
|
42
|
+
-----
|
|
43
|
+
|
|
44
|
+
Please see the brief `demo Jupyter notebook`_. It's very brief. I need to add more. The whole package is basically two functions. Please read the help:
|
|
45
|
+
|
|
46
|
+
``makemycv``
|
|
47
|
+
~~~~~~~~~~~~
|
|
48
|
+
|
|
49
|
+
To do anything useful here, you must have `LaTeX`_ with BibTeX installed. If you don't use `LaTeX`_, this module isn't the place to start. Sorry.
|
|
50
|
+
|
|
51
|
+
The first function here, ``makemycv``, will take a few arguments and put sorted ``\bibentry`` commands into ``.tex`` files with names corresponding to `BibTeX entry <https://en.wikibooks.org/wiki/LaTeX/Bibliography_Management#BibTeX>`_ types. In doing so, you can then simply use an ``\input`` command to embed all of these citations right in your document in an enumerated environment.
|
|
52
|
+
|
|
53
|
+
You'll need the following in the header of your LaTeX cv file.
|
|
54
|
+
|
|
55
|
+
.. code::
|
|
56
|
+
|
|
57
|
+
\usepackage{bibentry}
|
|
58
|
+
\newcommand{\enquote}[1]{``#1''}
|
|
59
|
+
\makeatletter\let\saved@bibitem\@bibitem\makeatother
|
|
60
|
+
\usepackage[colorlinks=true]{hyperref}
|
|
61
|
+
\makeatletter\let\@bibitem\saved@bibitem\makeatother
|
|
62
|
+
|
|
63
|
+
The last 3 lines are only necessary if you want to use the ``hyperref`` package, which has some compatibility issues with bibentry.
|
|
64
|
+
|
|
65
|
+
Then put:
|
|
66
|
+
|
|
67
|
+
.. code::
|
|
68
|
+
|
|
69
|
+
\input{articles.tex}
|
|
70
|
+
|
|
71
|
+
where you want articles listed, etc.
|
|
72
|
+
|
|
73
|
+
Then, with your maintained `.bib` file, in the same location as your cv (for now), and **within the same directory as your cv and cv.bib file** open a python terminal and type.
|
|
74
|
+
|
|
75
|
+
.. code::
|
|
76
|
+
|
|
77
|
+
>>> import vitae
|
|
78
|
+
>>> vitae.makemycv()
|
|
79
|
+
|
|
80
|
+
Alternatively, you can type::
|
|
81
|
+
|
|
82
|
+
> python -c "import vitae; vitae.makemycv()"
|
|
83
|
+
|
|
84
|
+
in your terminal (Anaconda Terminal if you are using Anaconda Python on Windows).
|
|
85
|
+
|
|
86
|
+
This will make your ``article.tex`` file along with the other defaults (see the help on ``makemycv``).
|
|
87
|
+
|
|
88
|
+
Note that that are a ton of options for ``makemycv``. Please use::
|
|
89
|
+
|
|
90
|
+
>>> import vitae
|
|
91
|
+
>>> help(vitae.makemycv)
|
|
92
|
+
|
|
93
|
+
To see how to tweak it to your needs.
|
|
94
|
+
|
|
95
|
+
If you try ``vitae``, please understand:
|
|
96
|
+
|
|
97
|
+
a. No warrantee. This is still a work in progress.
|
|
98
|
+
b. Please provide your feedback.
|
|
99
|
+
c. Please help! I can use help with additional portions.
|
|
100
|
+
|
|
101
|
+
If you don't use LaTeX, this isn't easy enough for you yet. It's a long ways away. However, texblog_ has a decent start in writing a `Résumé in LaTeX`_ . It *doesn't* include the paper inclusion trick being used by ``vitae``.
|
|
102
|
+
|
|
103
|
+
``write_bibs``
|
|
104
|
+
~~~~~~~~~~~~~~
|
|
105
|
+
|
|
106
|
+
The second function is ``write_bibs``. This allows you to convert bibs with a bunch of constraints into a format that pandoc_ can output. It REQUIRES a full `LaTeX`_ and pandoc_ installation that works in your terminal environment.
|
|
107
|
+
|
|
108
|
+
Constraints include:
|
|
109
|
+
|
|
110
|
+
1. Since a year
|
|
111
|
+
2. Number
|
|
112
|
+
3. Types of publications
|
|
113
|
+
|
|
114
|
+
For instance:
|
|
115
|
+
|
|
116
|
+
.. code::
|
|
117
|
+
|
|
118
|
+
>>> import vitae
|
|
119
|
+
>>> vitae.write_bibs(bibfile = '/Users/jslater/Documents/Resumes/cv.bib',
|
|
120
|
+
bibliographystyle='aiaa',
|
|
121
|
+
outfile_name='try.html',
|
|
122
|
+
since_year=2008)
|
|
123
|
+
|
|
124
|
+
Alternatively, from a command line::
|
|
125
|
+
|
|
126
|
+
> python -c "import vitae; vitae.write_bibs(bibfile='cv.bib',
|
|
127
|
+
bibliographystyle='aiaa',
|
|
128
|
+
outfile_name = 'bibs.html',
|
|
129
|
+
since_year=2008)"
|
|
130
|
+
|
|
131
|
+
How I use it
|
|
132
|
+
------------
|
|
133
|
+
|
|
134
|
+
I have a Makefile that I use for tasks that I am creating. The first is a simple one for building my cv, the contents of which are::
|
|
135
|
+
|
|
136
|
+
help:
|
|
137
|
+
@echo "Please use \`make <target>' where <target> is one of"
|
|
138
|
+
@echo " cv to make standard pdf cv"
|
|
139
|
+
@echo " pdf see cv"
|
|
140
|
+
|
|
141
|
+
cv:
|
|
142
|
+
python -c 'import vitae; vitae.makemycv(silent = True)'
|
|
143
|
+
pdflatex cv
|
|
144
|
+
bibtex cv
|
|
145
|
+
pdflatex cv
|
|
146
|
+
|
|
147
|
+
pdf:
|
|
148
|
+
cv
|
|
149
|
+
|
|
150
|
+
Summary
|
|
151
|
+
-------
|
|
152
|
+
Please see the full help on each function.
|
|
153
|
+
|
|
154
|
+
Vitae is on pypi_ but you can pip install the latest, and possibly non-working, version right now from github (I love bug reports!):
|
|
155
|
+
|
|
156
|
+
.. code::
|
|
157
|
+
|
|
158
|
+
pip install git+https://github.com/josephcslater/vitae
|
|
159
|
+
|
|
160
|
+
Help
|
|
161
|
+
----
|
|
162
|
+
``vitae`` uses luatex_ to enable unicode characters. On Ubuntu, the base tetex install doesn't include the necessary file ``luaotfload``. To resolve this open a terminal and type::
|
|
163
|
+
|
|
164
|
+
sudo apt install texlive-luatex
|
|
165
|
+
|
|
166
|
+
Release notes:
|
|
167
|
+
--------------
|
|
168
|
+
|
|
169
|
+
See the CHANGELOG_ for the full history of releases.
|
|
170
|
+
|
|
171
|
+
Future plans
|
|
172
|
+
------------
|
|
173
|
+
|
|
174
|
+
1. Preferences.
|
|
175
|
+
|
|
176
|
+
a. Reader (doesn't overwrite specified arguments)
|
|
177
|
+
|
|
178
|
+
b. Writer (configurator on call or when it doesn't exist)
|
|
179
|
+
|
|
180
|
+
c. Editor?
|
|
181
|
+
|
|
182
|
+
2. Bug fixes when I find them. Any other suggestions?
|
|
183
|
+
|
|
184
|
+
What else would be nice?
|
|
185
|
+
|
|
186
|
+
.. _CHANGELOG: https://github.com/josephcslater/vitae/blob/master/CHANGELOG.rst
|
|
187
|
+
.. _pandoc: http://pandoc.org
|
|
188
|
+
.. _luatex: http://www.luatex.org
|
|
189
|
+
.. _texblog: https://texblog.org
|
|
190
|
+
.. _`Résumé in LaTeX`: https://texblog.org/2012/04/25/writing-a-cv-in-latex/
|
|
191
|
+
.. _`LaTeX`: https://www.latex-tutorial.com/installation/
|
|
192
|
+
.. _bibtexparser: https://bibtexparser.readthedocs.io/en/master/
|
|
193
|
+
.. _Jupyter: https://www.Jupyter.org
|
|
194
|
+
.. _Makefile: https://www.gnu.org/software/make/manual/html_node/Introduction.html
|
|
195
|
+
.. _`demo Jupyter notebook`: https://github.com/josephcslater/vitae/blob/master/Vitae.ipynb
|
|
196
|
+
.. _pypi: https://pypi.org/project/vitae/
|
|
197
|
+
|
|
198
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
vitae
|