Minimum Intrusion Grid (MiG) Utilities library
Project description
.. image:: https://travis-ci.org/rasmunk/mig_utils.svg?branch=master
:target: https://travis-ci.org/rasmunk/mig_utils
.. |br| raw:: html
<br />
=========
mig_utils
=========
A Minimum Intrusion Grid(MiG) utilities python library: |br|
Includes the mig.io module that provides access to MiG Sharelinks through
python by wrapping around (https://github.com/althonos/fs.sshfs) for sshfs
connections.
------------
Installation
------------
Installation from pypi::
pip install mig-utils
Installation from a local git repository::
cd mig-utils
pip install .
-------
IO Example
-------
ERDA (https://erda.dk) sharelink access with python3 example::
# First import the class that gives you access to the share in question*
from mig.io import ErdaShare
# Initialize sharelink
share = ErdaShare('SHARELINKID')
# List files/dirs in share
print(share.list())
# Read file directly as string
print(share.read('tmp'))
# Read file directly as binary
print(str(share.read_binary('tmp')))
# Get a _io.TextIOWrapper object with automatic close
with share.open('tmp', 'r') as tmp:
print(tmp.read())
# Get a default _io.TextIOWrapper object with manual lifetime
file = share.open('tmp', 'r')
print(file.read())
file.close()
# Writing strings to a file
test_string = "Hello There"
test_num = 42342342
test_float = 3434.231
with share.open('write_test', 'w') as w_file:
w_file.write(test_string)
w_file.write(str(test_num))
w_file.write(str(test_float))
# Writing bytes to a file
test_binary = b'Hello again'
test_b_num = (255).to_bytes(1, byteorder=sys.byteorder)
with share.open('binary_test', 'wb') as b_file:
b_file.write(test_binary)
b_file.write(test_b_num)
# Removing files, likewise for dirs by using share.removedir(path)
share.remove('writes_test')
share.remove('binary_test')
A likewise sharelink class exists for IDMC (https://idmc.dk)
:target: https://travis-ci.org/rasmunk/mig_utils
.. |br| raw:: html
<br />
=========
mig_utils
=========
A Minimum Intrusion Grid(MiG) utilities python library: |br|
Includes the mig.io module that provides access to MiG Sharelinks through
python by wrapping around (https://github.com/althonos/fs.sshfs) for sshfs
connections.
------------
Installation
------------
Installation from pypi::
pip install mig-utils
Installation from a local git repository::
cd mig-utils
pip install .
-------
IO Example
-------
ERDA (https://erda.dk) sharelink access with python3 example::
# First import the class that gives you access to the share in question*
from mig.io import ErdaShare
# Initialize sharelink
share = ErdaShare('SHARELINKID')
# List files/dirs in share
print(share.list())
# Read file directly as string
print(share.read('tmp'))
# Read file directly as binary
print(str(share.read_binary('tmp')))
# Get a _io.TextIOWrapper object with automatic close
with share.open('tmp', 'r') as tmp:
print(tmp.read())
# Get a default _io.TextIOWrapper object with manual lifetime
file = share.open('tmp', 'r')
print(file.read())
file.close()
# Writing strings to a file
test_string = "Hello There"
test_num = 42342342
test_float = 3434.231
with share.open('write_test', 'w') as w_file:
w_file.write(test_string)
w_file.write(str(test_num))
w_file.write(str(test_float))
# Writing bytes to a file
test_binary = b'Hello again'
test_b_num = (255).to_bytes(1, byteorder=sys.byteorder)
with share.open('binary_test', 'wb') as b_file:
b_file.write(test_binary)
b_file.write(test_b_num)
# Removing files, likewise for dirs by using share.removedir(path)
share.remove('writes_test')
share.remove('binary_test')
A likewise sharelink class exists for IDMC (https://idmc.dk)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mig-utils-0.1.1.tar.gz
(3.1 kB
view hashes)
Built Distributions
mig_utils-0.1.1-py3.6.egg
(5.4 kB
view hashes)
Close
Hashes for mig_utils-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 04d6c1862c7ffa62a25c4b7b33944c88a67210e6e282f032613876a4a325e7a8 |
|
MD5 | 4c4bc17c744a51424179a32a58f8bda2 |
|
BLAKE2b-256 | af22574a4a00072c18c4daeca24519ac5c1cf500b076c3a90d6cf6df79670a77 |