Skip to content

Commit f7ffff0

Browse files
first commit 🍉 (#1)
1 parent 104662c commit f7ffff0

7 files changed

Lines changed: 127 additions & 1 deletion

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,4 @@ venv.bak/
102102

103103
# mypy
104104
.mypy_cache/
105+
.idea

Makefile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
.PHONY: release test
2+
3+
4+
artifacts:
5+
python setup.py sdist bdist_wheel
6+
7+
8+
clean:
9+
rm -rf dist/
10+
11+
12+
prepforbuild:
13+
pip install --upgrade twine setuptools wheel
14+
15+
16+
uploadtest:
17+
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
18+
19+
20+
release: clean artifacts
21+
twine upload --repository-url https://upload.pypi.org/legacy/ dist/*
22+
23+
test:
24+
python -m pytest
25+

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
# Gallerist-AzureStorage
2-
Gallerist classes for Azure Storage
2+
Gallerist classes for Azure Storage: implements reading image files from Azure Blob Service and write there resized pictures.
3+
4+
```bash
5+
$ pip install gallerist-azurestorage
6+
```
7+

azure-pipelines.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Python package
2+
# Create and test a Python package on multiple Python versions.
3+
# Add steps that analyze code, save the dist with the build record, publish to a PyPI-compatible index, and more:
4+
# https://docs.microsoft.com/azure/devops/pipelines/languages/python
5+
6+
trigger:
7+
- master
8+
9+
pool:
10+
vmImage: 'ubuntu-latest'
11+
strategy:
12+
matrix:
13+
Python37:
14+
python.version: '3.7'
15+
16+
steps:
17+
- task: UsePythonVersion@0
18+
inputs:
19+
versionSpec: '$(python.version)'
20+
displayName: 'Use Python $(python.version)'
21+
22+
- script: |
23+
python -m pip install --upgrade pip
24+
pip install -r requirements.txt
25+
displayName: 'Install dependencies'
26+
27+
- script: |
28+
pip install --upgrade twine setuptools wheel
29+
python setup.py sdist bdist_wheel
30+
displayName: 'create artifacts'
31+
32+
- task: PublishBuildArtifacts@1
33+
inputs:
34+
pathtoPublish: dist
35+
artifactName: 'dist_$(python.version)'
36+
displayName: 'publish artifacts'

galleristazurestorage/__init__.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from gallerist.abc import SyncFileStore
2+
from azure.storage.common import CloudStorageAccount
3+
4+
5+
class AzureBlobFileStore(SyncFileStore):
6+
7+
def __init__(self, account: CloudStorageAccount, container_name: str):
8+
self.account = account
9+
self.service = account.create_block_blob_service()
10+
self.container_name = container_name
11+
12+
@classmethod
13+
def from_name_and_key(cls,
14+
account_name: str,
15+
account_key: str,
16+
container_name: str):
17+
return cls(CloudStorageAccount(account_name=account_name, account_key=account_key), container_name)
18+
19+
def read_file(self, file_path: str) -> bytes:
20+
blob = self.service.get_blob_to_bytes(self.container_name, file_path)
21+
return blob.content
22+
23+
def write_file(self, file_path: str, data: bytes):
24+
self.service.create_blob_from_bytes(self.container_name, file_path, data)
25+
26+
def delete_file(self, file_path: str):
27+
self.service.delete_blob(self.container_name, file_path)
28+

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
gallerist
2+
azure-storage-blob

setup.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from setuptools import setup
2+
3+
4+
def readme():
5+
with open('README.md') as f:
6+
return f.read()
7+
8+
9+
setup(name='gallerist-azurestorage',
10+
version='0.0.1',
11+
description='Azure Storage file store for Gallerist',
12+
long_description=readme(),
13+
long_description_content_type='text/markdown',
14+
classifiers=[
15+
'Development Status :: 3 - Alpha',
16+
'License :: OSI Approved :: MIT License',
17+
'Programming Language :: Python :: 3',
18+
'Operating System :: OS Independent'
19+
],
20+
url='https://github.com/RobertoPrevato/Gallerist-AzureStorage',
21+
author='RobertoPrevato',
22+
author_email='roberto.prevato@gmail.com',
23+
keywords='pictures images web azure storage',
24+
license='MIT',
25+
packages=['galleristazurestorage'],
26+
install_requires=['gallerist',
27+
'azure-storage-blob'],
28+
include_package_data=True,
29+
zip_safe=False)

0 commit comments

Comments
 (0)