Skip to content

Commit

Permalink
Added and fixed some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Rahul Gurujala committed Aug 8, 2024
1 parent aaa01c8 commit 0bb0756
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 6 deletions.
15 changes: 15 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[flake8]
max-line-length = 120
extend-ignore = E203, E266, E501, W503
max-complexity = 18
select = B,C,E,F,W,T4,B9
exclude =
.git,
__pycache__,
build,
dist,
venv,
.venv
per-file-ignores =
# imported but unused
__init__.py: F401
5 changes: 5 additions & 0 deletions excel_helper/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from .excel_helper import ExcelHelper

__all__ = ["ExcelHelper"]

__version__ = "0.1.0"
7 changes: 4 additions & 3 deletions excel_helper/excel_helper.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from typing import Any, Dict, List

import openpyxl
from openpyxl.utils import get_column_letter
from openpyxl.formula.translate import Translator
from typing import List, Dict, Any
from openpyxl.utils import get_column_letter


class ExcelHelper:
Expand Down Expand Up @@ -89,7 +90,7 @@ def auto_fit_columns(self):
try:
if len(str(cell.value)) > max_length:
max_length = len(cell.value)
except:
except Exception:
pass
adjusted_width = max_length + 2
self.active_sheet.column_dimensions[column_letter].width = adjusted_width
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from setuptools import setup, find_packages
from setuptools import find_packages, setup

with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read()
Expand Down Expand Up @@ -29,4 +29,4 @@
install_requires=[
"openpyxl>=3.0.0",
],
)
)
4 changes: 4 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import os
import sys

sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
7 changes: 6 additions & 1 deletion tests/test_excel_helper.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import pytest
import os

import pytest

from excel_helper import ExcelHelper


Expand Down Expand Up @@ -117,3 +119,6 @@ def test_auto_fit_columns(excel_helper):
excel_helper.active_sheet.column_dimensions["A"].width
< excel_helper.active_sheet.column_dimensions["B"].width
)

if __name__ == "__main__":
pytest.main([__file__])

0 comments on commit 0bb0756

Please sign in to comment.