histrio / python-descript-ion Goto Github PK
View Code? Open in Web Editor NEWSimple library for `descript.ion` files manipulation
License: Apache License 2.0
Simple library for `descript.ion` files manipulation
License: Apache License 2.0
When installed using pip
, only metadata are installed, no module code:
$ pip3 show -f descript
Name: descript
Version: 0.0.1
Summary: UNKNOWN
Home-page: https://github.com/histrio/python-descript-ion
Author: Rinat F Sabitov
Author-email: [email protected]
License: UNKNOWN
Location: /usr/local/lib/python3.7/dist-packages
Requires:
Required-by:
Files:
descript-0.0.1.dist-info/INSTALLER
descript-0.0.1.dist-info/METADATA
descript-0.0.1.dist-info/RECORD
descript-0.0.1.dist-info/WHEEL
descript-0.0.1.dist-info/top_level.txt
With pytest + tmpfile made up some nasty example cases, for example:
It's not a big problem, but I believe that git conflict file descript/ion.py.orig
was submitted to the pypi repository by mistake:
# pip3 show -f descript
Name: descript
Version: 0.1.1
Summary: Simple library for `descript.ion` files manipulation.
Home-page: https://github.com/histrio/python-descript-ion
Author: Rinat Sabitov
Author-email: [email protected]
License: Apache-2.0
Location: /usr/local/lib/python3.7/dist-packages
Requires:
Required-by:
Files:
descript-0.1.1.dist-info/INSTALLER
descript-0.1.1.dist-info/LICENSE.md
descript-0.1.1.dist-info/METADATA
descript-0.1.1.dist-info/RECORD
descript-0.1.1.dist-info/WHEEL
descript/__init__.py
descript/__pycache__/__init__.cpython-37.pyc
descript/__pycache__/ion.cpython-37.pyc
descript/ion.py
descript/ion.py.orig
Я использую:
I use:
Вот файл test.py, который падает с ошибкой:
Here is the file test.py that fails:
import descript.ion
with descript.ion.open('.\\test.py') as f:
f.description = 'Description 1'
# Файл 'descript.ion' создался и содержит описание test.py
# File 'descript.ion' created; it contains the description of test.py
with descript.ion.open('.\\test.py') as f:
f.description = 'Description 2'
# Traceback (most recent call last):
# File "D:\V\Programs\Python\description\test.py", line 8, in <module>
# f.description = 'Description 2'
# File "C:\Program Files\Python\lib\site-packages\descript\ion.py", line 97, in __set__
# self[obj.name] = val
# File "C:\Program Files\Python\lib\site-packages\descript\ion.py", line 87, in __setitem__
# del self[key]
# File "C:\Program Files\Python\lib\site-packages\descript\ion.py", line 91, in __delitem__
# delete_key(key)
# File "C:\Program Files\Python\lib\site-packages\descript\ion.py", line 42, in wrapper
# return clbl(dfile, key, *args, **kwargs)
# File "C:\Program Files\Python\lib\site-packages\descript\ion.py", line 60, in delete_key
# copyfile(dst.name, dfile)
# File "C:\Program Files\Python\lib\shutil.py", line 259, in copyfile
# with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst:
# PermissionError: [Errno 13] Permission denied: 'C:\\TEMP\\tmp_o6x646l'
Для отладки я добавил строку в ion.py:
I added debug line into ion.py:
input("Temporary file: "+dst.name)
# Здесь я проверил, что временный файл существует и доступен для чтения
# Here I checked that the temporary file exists and is readable
copyfile(dst.name, dfile)
Возможно, проблема в этом:
This may be the reason of the problem:
https://docs.python.org/3/library/tempfile.html#tempfile.NamedTemporaryFile:
Whether the name can be used to open the file a second time, while the named temporary file is still open, varies across platforms (it can be so used on Unix; it cannot on Windows NT or later).
Возможные изменения в функции delete_key(dfile, key)
Possible changes in function delete_key(dfile, key):
...
dst = tempfile.NamedTemporaryFile('w+', delete = False)
with native_open(dfile, 'r') as src:
...
dst.close()
copyfile(dst.name, dfile)
os.remove(dst.name)
...
Need to rewrite test cases located here using pytest library
When filename with path used in descript.ion.open, the path is stored in descript.ion file. It should not! And vice versa, when reading description using filename with path, the procedure does not read descriptions of filenames which were stored without path.
Try to set file description which starts with "\n" symbol and then read it, you'll get an error.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.