printsection 0.1.0__tar.gz → 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: printsection
3
- Version: 0.1.0
3
+ Version: 0.2.0
4
4
  Summary: 출력 구간을 나누는 위아래 빈 줄 + 가운데 정렬 구분선 (한글 폭 자동 보정)
5
5
  License-Expression: MIT
6
6
  License-File: LICENSE
@@ -18,14 +18,15 @@ Description-Content-Type: text/markdown
18
18
 
19
19
  ```bash
20
20
  pip install printsection
21
+ # uv 사용 시: uv add printsection
21
22
  ```
22
23
 
23
24
  ```python
24
- from printsection import section
25
+ from printsection import print_section
25
26
 
26
- section("실습 1")
27
+ print_section("실습 1")
27
28
  print("...")
28
- section("실습 2")
29
+ print_section("실습 2")
29
30
  ```
30
31
 
31
32
  ```
@@ -45,11 +46,11 @@ section("실습 2")
45
46
  호출할 때 원하는 값만 바꾸면 됩니다.
46
47
 
47
48
  ```python
48
- section("실습 결과", width=60, fillchar="=")
49
- section("왼쪽 정렬", align="left") # "center" / "left" / "right"
50
- section("빈 줄 조절", top=2, bottom=0)
51
- section("str.center처럼", wide=False) # 글자 수 기준으로 계산
52
- section() # 글자 없이 구분선만
49
+ print_section("실습 결과", width=60, fillchar="=")
50
+ print_section("왼쪽 정렬", align="left") # "center" / "left" / "right"
51
+ print_section("빈 줄 조절", top=2, bottom=0)
52
+ print_section("str.center처럼", wide=False) # 글자 수 기준으로 계산
53
+ print_section() # 글자 없이 구분선만
53
54
  ```
54
55
 
55
56
  | 옵션 | 기본값 | 설명 |
@@ -65,11 +66,11 @@ section() # 글자 없이 구분선만
65
66
  ## 기본값 한 번에 바꾸기
66
67
 
67
68
  ```python
68
- from printsection import section, set_defaults, reset_defaults
69
+ from printsection import print_section, set_defaults, reset_defaults
69
70
 
70
71
  set_defaults(width=70, fillchar="*")
71
- section("1번 문제")
72
- section("2번 문제")
72
+ print_section("1번 문제")
73
+ print_section("2번 문제")
73
74
  reset_defaults()
74
75
  ```
75
76
 
@@ -5,14 +5,15 @@
5
5
 
6
6
  ```bash
7
7
  pip install printsection
8
+ # uv 사용 시: uv add printsection
8
9
  ```
9
10
 
10
11
  ```python
11
- from printsection import section
12
+ from printsection import print_section
12
13
 
13
- section("실습 1")
14
+ print_section("실습 1")
14
15
  print("...")
15
- section("실습 2")
16
+ print_section("실습 2")
16
17
  ```
17
18
 
18
19
  ```
@@ -32,11 +33,11 @@ section("실습 2")
32
33
  호출할 때 원하는 값만 바꾸면 됩니다.
33
34
 
34
35
  ```python
35
- section("실습 결과", width=60, fillchar="=")
36
- section("왼쪽 정렬", align="left") # "center" / "left" / "right"
37
- section("빈 줄 조절", top=2, bottom=0)
38
- section("str.center처럼", wide=False) # 글자 수 기준으로 계산
39
- section() # 글자 없이 구분선만
36
+ print_section("실습 결과", width=60, fillchar="=")
37
+ print_section("왼쪽 정렬", align="left") # "center" / "left" / "right"
38
+ print_section("빈 줄 조절", top=2, bottom=0)
39
+ print_section("str.center처럼", wide=False) # 글자 수 기준으로 계산
40
+ print_section() # 글자 없이 구분선만
40
41
  ```
41
42
 
42
43
  | 옵션 | 기본값 | 설명 |
@@ -52,11 +53,11 @@ section() # 글자 없이 구분선만
52
53
  ## 기본값 한 번에 바꾸기
53
54
 
54
55
  ```python
55
- from printsection import section, set_defaults, reset_defaults
56
+ from printsection import print_section, set_defaults, reset_defaults
56
57
 
57
58
  set_defaults(width=70, fillchar="*")
58
- section("1번 문제")
59
- section("2번 문제")
59
+ print_section("1번 문제")
60
+ print_section("2번 문제")
60
61
  reset_defaults()
61
62
  ```
62
63
 
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "printsection"
7
- version = "0.1.0"
7
+ version = "0.2.0"
8
8
  description = "출력 구간을 나누는 위아래 빈 줄 + 가운데 정렬 구분선 (한글 폭 자동 보정)"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"
@@ -1,7 +1,7 @@
1
1
  """위아래 빈 줄과 가운데 정렬이 기본으로 들어간 구간 구분 출력 함수.
2
2
 
3
- >>> from printsection import section
4
- >>> section("실습 결과")
3
+ >>> from printsection import print_section
4
+ >>> print_section("실습 결과")
5
5
 
6
6
  --------------------실습 결과---------------------
7
7
 
@@ -10,8 +10,8 @@
10
10
  import sys
11
11
  import unicodedata
12
12
 
13
- __all__ = ["section", "format_section", "set_defaults", "reset_defaults"]
14
- __version__ = "0.1.0"
13
+ __all__ = ["print_section", "format_section", "set_defaults", "reset_defaults"]
14
+ __version__ = "0.2.0"
15
15
 
16
16
  _FACTORY_DEFAULTS = {
17
17
  "width": 50,
@@ -59,7 +59,7 @@ def format_section(text="", **options):
59
59
  return "\n" * opt["top"] + line + "\n" * opt["bottom"]
60
60
 
61
61
 
62
- def section(text="", *, file=None, flush=False, **options):
62
+ def print_section(text="", *, file=None, flush=False, **options):
63
63
  """구간 이름을 위아래 빈 줄과 함께 가운데 정렬해서 출력한다.
64
64
 
65
65
  옵션 (생략하면 set_defaults로 정한 값, 처음엔 아래 기본값):
@@ -73,8 +73,12 @@ def section(text="", *, file=None, flush=False, **options):
73
73
  print(format_section(text, **options), file=file or sys.stdout, flush=flush)
74
74
 
75
75
 
76
+ # 0.1.0 호환용 옛 이름
77
+ section = print_section
78
+
79
+
76
80
  def set_defaults(**options):
77
- """이후 모든 section() 호출의 기본값을 바꾼다. 예: set_defaults(width=60, fillchar="=")"""
81
+ """이후 모든 print_section() 호출의 기본값을 바꾼다. 예: set_defaults(width=60, fillchar="=")"""
78
82
  unknown = set(options) - set(_FACTORY_DEFAULTS)
79
83
  if unknown:
80
84
  raise TypeError(f"알 수 없는 옵션: {', '.join(sorted(unknown))}")
@@ -1,6 +1,7 @@
1
1
  import pytest
2
2
 
3
- from printsection import format_section, reset_defaults, set_defaults
3
+ import printsection
4
+ from printsection import format_section, print_section, reset_defaults, set_defaults
4
5
 
5
6
 
6
7
  @pytest.fixture(autouse=True)
@@ -45,3 +46,9 @@ def test_bad_options():
45
46
  format_section("a", fillchar="--")
46
47
  with pytest.raises(ValueError):
47
48
  format_section("a", align="middle")
49
+
50
+
51
+ def test_print_section_output(capsys):
52
+ print_section("ab", width=4, top=1, bottom=1)
53
+ assert capsys.readouterr().out == "\n-ab-\n\n"
54
+ assert printsection.section is print_section
File without changes