Compare commits
No commits in common. '5a31ad0ce4fb927124075cc3772d3ea7b233aaa9' and '32d4ddbe8077bfb1b277a6b40aaf8de3949bdd7e' have entirely different histories.
5a31ad0ce4
...
32d4ddbe80
16 changed files with 0 additions and 245 deletions
@ -1,25 +0,0 @@
@@ -1,25 +0,0 @@
|
||||
#include <iostream> |
||||
#include <string> |
||||
#include "custom.h" |
||||
|
||||
proto::proto(std::string cname) |
||||
{ |
||||
std::cout<< "FFFFUUUUU" <<std::endl; |
||||
} |
||||
|
||||
void proto::setname(std::string bname) |
||||
{ |
||||
name = bname; |
||||
} |
||||
|
||||
|
||||
std::string proto::getname() |
||||
{ |
||||
return name; |
||||
} |
||||
|
||||
proto::~proto(){ |
||||
std::cout << "I am destroyed" << std::endl; |
||||
} |
||||
|
||||
//g++ custom_user.cpp custom.cpp -o custom
|
@ -1,15 +0,0 @@
@@ -1,15 +0,0 @@
|
||||
#ifndef STUPID_H |
||||
#define STUPID_H |
||||
|
||||
class proto{ |
||||
public: |
||||
proto(std::string cname); |
||||
//proto();
|
||||
void setname(std::string bname); |
||||
std::string getname(); |
||||
~proto(); |
||||
private: |
||||
std::string name; |
||||
|
||||
}; |
||||
#endif |
@ -1,22 +0,0 @@
@@ -1,22 +0,0 @@
|
||||
#include <iostream> |
||||
#include <string> |
||||
#include "custom.h" |
||||
#include <unistd.h> |
||||
//for sleepings
|
||||
unsigned int microsec; |
||||
|
||||
int main(){ |
||||
proto obj("WTF"); |
||||
std::cout<< obj.getname() << std::endl; |
||||
obj.setname("Paul Lesack"); |
||||
std::cout << obj.getname() <<std::endl; |
||||
microsec=100*1000; |
||||
usleep(microsec); |
||||
|
||||
for (int x=1; x<10; x++) |
||||
{ |
||||
std::cout << "Sleeping" << std::endl; |
||||
} |
||||
|
||||
return 0; |
||||
} |
@ -1,28 +0,0 @@
@@ -1,28 +0,0 @@
|
||||
## Documentation |
||||
|
||||
A good example of a user guide is here: <https://pydataverse.readthedocs.io/en/latest/developer.html> |
||||
|
||||
### Pydoc-markdown |
||||
|
||||
This option gives control over the order in which things are arranged in the API document: |
||||
|
||||
`pydoc-markdown -I ./ -m dryad2dataverse -m dryad2dataverse.constants -m dryad2dataverse.serializer -m dryad2dataverse.transfer -m dryad2dataverse.monitor -m dryad2dataverse.exceptions --render-toc > api_reference.md` |
||||
|
||||
or, after it's installed (with pip -e ./) |
||||
|
||||
`pydoc-markdown -p dryad2dataverse > api_reference.md` |
||||
|
||||
or |
||||
|
||||
`pydoc-markdown -p dryad2dataverse --render-toc > api_reference.md` |
||||
|
||||
Edit manually as required (but hopefully not) |
||||
|
||||
Write the `_config.yml` and `pydoc-markdown.yml` manually |
||||
|
||||
HTML hierarchies are automatically created with a top level heading (`#`) and subheadings. |
||||
|
||||
In the case of pydoc markdown, it's useful to create the docmentation as above, and then add an extra (`#`) to the headings. Then add a heading for the entire page. This is because each source file will create its own `<h1>` tag. |
||||
|
||||
If local, you can switch to the top dir and run `mkdocs serve`, and/or automatically create github pages by using `mkdocs gh-deploy`. See <https://www.mkdocs.org/user-guide/deploying-your-docs/> |
||||
|
@ -1,15 +0,0 @@
@@ -1,15 +0,0 @@
|
||||
## Notes on creating documentation |
||||
|
||||
Use pydoc-markdown: |
||||
|
||||
<https://pypi.org/project/pydoc-markdown/> |
||||
|
||||
`pydoc-markdown -p dryad2dataverse --render-toc > outputfile.md` |
||||
|
||||
Note the `-p` switch for loading a package instead of a single module (ie, `-m`) |
||||
|
||||
Can be used with mkdocs to produce JustTheDocs format static pages: |
||||
|
||||
<https://www.mkdocs.org/> |
||||
|
||||
|
@ -1,9 +0,0 @@
@@ -1,9 +0,0 @@
|
||||
# Python time conversions |
||||
x = datetime.datetime.now() |
||||
x.strftime('%Y-%m-%d %H:%M:%S') |
||||
'2021-11-30 08:11:51' |
||||
|
||||
String to datetime: datetime.strptime |
||||
|
||||
z=datetime.strptime(y, '%Y-%m-%d %H:%M:%S') #python 3.8 + dammit |
||||
datetime.datetime(*(time.strptime(y, '%Y-%m-%d %H:%M:%S')[0:6]))#painful |
@ -1,31 +0,0 @@
@@ -1,31 +0,0 @@
|
||||
''' |
||||
Chronological file backup example |
||||
''' |
||||
|
||||
import datetime |
||||
import time |
||||
|
||||
#to generate a date: |
||||
#x=datetime.datetime.now().strftime('%Y-%m-%d') |
||||
|
||||
#Sample dates |
||||
DATES = ['2021-01-07', '2021-02-14', '2021-06-22', |
||||
'2021-04-14', '2021-03-19', '2021-07-11', '2021-05-14'] |
||||
|
||||
#sample file names |
||||
FNAMES = ['SP_dryad_production.sqlite3.'+ x for x in DATES] |
||||
|
||||
#Note: min max etc work on dictionary keys |
||||
#datetime.datetime(*(time.strptime(y, '%Y-%m-%d %H:%M:%S')[0:6]))#painful |
||||
#see https://python.readthedocs.io/en/latest/library/datetime.html |
||||
|
||||
FNAME_D={datetime.datetime( |
||||
*(time.strptime(dat[-10:],'%Y-%m-%d')[0:6])): dat |
||||
for dat in FNAMES} |
||||
TIMES = list(FNAME_D) |
||||
TIMES.sort() |
||||
#There can be only 3 |
||||
for fil in TIMES[3:]: |
||||
print(f'os.remove({FNAME_D[fil]})') |
||||
del FNAMES[FNAMES.index(FNAME_D[fil])] |
||||
print(FNAMES) |
@ -1,9 +0,0 @@
@@ -1,9 +0,0 @@
|
||||
import logging |
||||
|
||||
logger = logging.getLogger(__name__) |
||||
|
||||
def test1(): |
||||
logger.info('Ran log1.py test1()') |
||||
return 1 |
||||
|
||||
|
@ -1,10 +0,0 @@
@@ -1,10 +0,0 @@
|
||||
import logging |
||||
|
||||
logger = logging.getLogger(__name__) |
||||
|
||||
def test2(): |
||||
logger.info('Ran log2.py test2()') |
||||
return 1 |
||||
|
||||
|
||||
|
@ -1,16 +0,0 @@
@@ -1,16 +0,0 @@
|
||||
import logging |
||||
import log1 |
||||
import log2 |
||||
|
||||
# See also https://python101.pythonlibrary.org/chapter15_logging.html |
||||
|
||||
logger = logging.getLogger(__name__) |
||||
|
||||
logging.basicConfig(format='%(module)s - %(name)s - %(asctime)s -' |
||||
' %(funcName)s - %(message)s', filename='test.log', filemode='w', level=logging.INFO) |
||||
|
||||
#logging.basicConfig(filename='test.log', filemode='w', level=logging.INFO) |
||||
for i in range(10): |
||||
logger.info(f'called {i} times') |
||||
log1.test1() |
||||
log2.test2() |
@ -1,30 +0,0 @@
@@ -1,30 +0,0 @@
|
||||
main - __main__ - 2021-01-08 13:30:10,622 - <module> - called 0 times |
||||
log1 - log1 - 2021-01-08 13:30:10,622 - test1 - Ran log1.py test1() |
||||
log2 - log2 - 2021-01-08 13:30:10,622 - test2 - Ran log2.py test2() |
||||
main - __main__ - 2021-01-08 13:30:10,622 - <module> - called 1 times |
||||
log1 - log1 - 2021-01-08 13:30:10,622 - test1 - Ran log1.py test1() |
||||
log2 - log2 - 2021-01-08 13:30:10,622 - test2 - Ran log2.py test2() |
||||
main - __main__ - 2021-01-08 13:30:10,622 - <module> - called 2 times |
||||
log1 - log1 - 2021-01-08 13:30:10,622 - test1 - Ran log1.py test1() |
||||
log2 - log2 - 2021-01-08 13:30:10,622 - test2 - Ran log2.py test2() |
||||
main - __main__ - 2021-01-08 13:30:10,622 - <module> - called 3 times |
||||
log1 - log1 - 2021-01-08 13:30:10,622 - test1 - Ran log1.py test1() |
||||
log2 - log2 - 2021-01-08 13:30:10,622 - test2 - Ran log2.py test2() |
||||
main - __main__ - 2021-01-08 13:30:10,622 - <module> - called 4 times |
||||
log1 - log1 - 2021-01-08 13:30:10,623 - test1 - Ran log1.py test1() |
||||
log2 - log2 - 2021-01-08 13:30:10,623 - test2 - Ran log2.py test2() |
||||
main - __main__ - 2021-01-08 13:30:10,623 - <module> - called 5 times |
||||
log1 - log1 - 2021-01-08 13:30:10,623 - test1 - Ran log1.py test1() |
||||
log2 - log2 - 2021-01-08 13:30:10,623 - test2 - Ran log2.py test2() |
||||
main - __main__ - 2021-01-08 13:30:10,623 - <module> - called 6 times |
||||
log1 - log1 - 2021-01-08 13:30:10,623 - test1 - Ran log1.py test1() |
||||
log2 - log2 - 2021-01-08 13:30:10,623 - test2 - Ran log2.py test2() |
||||
main - __main__ - 2021-01-08 13:30:10,623 - <module> - called 7 times |
||||
log1 - log1 - 2021-01-08 13:30:10,623 - test1 - Ran log1.py test1() |
||||
log2 - log2 - 2021-01-08 13:30:10,623 - test2 - Ran log2.py test2() |
||||
main - __main__ - 2021-01-08 13:30:10,623 - <module> - called 8 times |
||||
log1 - log1 - 2021-01-08 13:30:10,623 - test1 - Ran log1.py test1() |
||||
log2 - log2 - 2021-01-08 13:30:10,623 - test2 - Ran log2.py test2() |
||||
main - __main__ - 2021-01-08 13:30:10,623 - <module> - called 9 times |
||||
log1 - log1 - 2021-01-08 13:30:10,623 - test1 - Ran log1.py test1() |
||||
log2 - log2 - 2021-01-08 13:30:10,623 - test2 - Ran log2.py test2() |
@ -1,3 +0,0 @@
@@ -1,3 +0,0 @@
|
||||
#Find complete path to a python file: |
||||
dir_path = os.path.dirname(os.path.realpath(__file__)) |
||||
|
Binary file not shown.
@ -1,32 +0,0 @@
@@ -1,32 +0,0 @@
|
||||
'''Images to and from sqlite''' |
||||
import io, sqlite3 |
||||
from PIL import Image |
||||
|
||||
#How to open a PIL image from a photostream |
||||
with open('test-pattern.png', 'rb') as x: |
||||
foto = x.read() |
||||
|
||||
fotostream = io.BytesIO(foto) |
||||
image = Image.open(fotostream) |
||||
|
||||
#And now for sqlite3 |
||||
|
||||
conn = sqlite3.Connection('imagetest.db') |
||||
cursor = conn.cursor() |
||||
|
||||
cursor.execute('CREATE TABLE IF NOT EXISTS images ("name" TEXT, "file" BLOB);') |
||||
|
||||
#make sure you insert the bytes from foto, not the io object |
||||
cursor.execute('INSERT INTO images VALUES (?,?)', ('testimage', foto)) |
||||
|
||||
#retrieval |
||||
cursor.execute('SELECT file from images') |
||||
f2stream = io.BytesIO(cursor.fetchone()[0]) #fetchone returns a tuple |
||||
f2img = Image.open(f2stream) |
||||
f2img = f2img.convert('RGB') # original is RGBA and generates an error |
||||
#see https://github.com/python-pillow/Pillow/issues/2609 |
||||
f2img.save('test-pattern_converted.jpg') |
||||
|
||||
#and save that data |
||||
conn.commit() |
||||
conn.close() |
Before Width: | Height: | Size: 45 KiB |
Before Width: | Height: | Size: 35 KiB |
Loading…
Reference in new issue