# flaretool
**flaretool** is flarebrow Library.
![License](https://img.shields.io/github/license/flarebrow/flaretool)
[![python](https://img.shields.io/badge/python-%3E%3D3.9-blue)](https://github.com/flarebrow/flaretool)
[![version](https://img.shields.io/github/v/release/flarebrow/flaretool?include_prereleases)](https://github.com/flarebrow/flaretool/releases/latest)
[![ReleaseDate](https://img.shields.io/github/release-date/flarebrow/flaretool)](https://github.com/flarebrow/flaretool/releases/latest)
![build](https://img.shields.io/github/actions/workflow/status/flarebrow/flaretool/auto_test.yml)
![Coverage](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/flarebrow/e31fc348a9dea0098de9540dc5961668/raw/pytest-coverage-3.9.json)
[![Downloads](https://static.pepy.tech/badge/flaretool)](https://pepy.tech/project/flaretool)
[API Doc](https://flarebrow.github.io/flaretool/)
**Attention**
This library is under development and may exhibit unexpected behavior. New features will be released soon. Please stay tuned.
## install
```bash
pip install flaretool
```
## NetTool usage
[NetTool Usage Document](https://flarebrow.github.io/flaretool/flaretool.nettool.html)
### NetTool Examples of usage
```python
from flaretool import nettool
# 指定されたIPアドレスの情報を取得する例
ip_info = nettool.get_global_ipaddr_info("192.168.0.1")
print("ip:", ip_info.ipaddr)
print("hostname:", ip_info.hostname)
print("country:", ip_info.country)
# 出力例:
# ip: 192.168.0.1
# hostname: example.com
# country: earth
# ドメイン名からIPアドレスを取得する例
ip_address = nettool.lookup_ip("example.com")
print(ip_address) # 123.456.789.001
# IPアドレスからドメイン名を取得する例
domain_name = nettool.lookup_domain("1.1.1.1")
print(domain_name) # one.one.one.one
# 指定されたIPアドレスが指定されたネットワークに属しているかどうかを判定する例
allowed_networks = ["192.168.0.0/24", "10.0.0.0/16"]
is_allowed = nettool.is_ip_in_allowed_networks(
"192.168.0.100", allowed_networks)
print(is_allowed) # True
# 指定されたドメイン名が存在するかどうかを判定する例
domain_exists = nettool.domain_exists("example.com")
print(domain_exists) # True
# 日本のIPアドレスのリストを取得する例
japan_ips = nettool.get_japanip_list()
print(japan_ips)
# 指定されたアドレスが日本のIPアドレスか確認する例
is_japan = nettool.is_japan_ip("203.0.113.1")
print(is_japan) # False
# 日本語を含むドメインをpunycodeに変換する例
puny_info = nettool.get_puny_code("日本語ドメイン.jp")
print("originalvalue:", puny_info.originalvalue)
print("encodevalue:", puny_info.encodevalue)
print("decodevalue:", puny_info.decodevalue)
# 出力例:
# originalvalue: 日本語ドメイン.jp
# encodevalue: xn--eckwd4c7c5976acvb2w6i.jp
# decodevalue: 日本語ドメイン.jp
# 特定のユーザーエージェントでスクレイピング可否を確認する例
url = "http://example.com/page.html"
user_agent = "MyScraperBot"
allowed = nettool.is_scraping_allowed(url, user_agent) # user_agentはオプション引数
if allowed:
print(f"{url} はユーザーエージェント '{user_agent}' でのスクレイピングが許可されています。")
else:
print(f"{url} はユーザーエージェント '{user_agent}' でのスクレイピングが禁止されています。")
```
### NetTool Command Examples of usage
```bash
flaretool nettool get_global_ipaddr_info
# usage
# flaretool nettool {FunctionName} [args...]
```
All methods within NetTool can be executed as commands.
### Help Command
```bash
flaretool nettool -h
```
## String utills usage
[String Utills Usage Document](https://flarebrow.github.io/flaretool/flaretool.html#module-flaretool.utills)
```python
from flaretool import utills
from flaretool.utills import ConversionMode
# 文字列変換
# 半角
value = "1234567896789"
result = utills.convert_value(value)
print(result) # "1234567896789"
# 全角
value = "Hello"
result = utills.convert_value(value, ConversionMode.FULL_WIDTH)
print(result) # "Hello"
# 文字列のみ半角
value = "ABCabc123"
result = utills.convert_value(
value, ascii=True, digit=False, kana=False)
print(result) # "ABCabc123"
# 小文字
value = "ABCabc"
result = utills.convert_value(
value, ConversionMode.LOWER)
print(result) # "abcabc"
# 大文字
value = "ABCabc"
result = utills.convert_value(
value, ConversionMode.UPPER)
print(result) # "ABCABC"
```
## JapaneseHoliday Examples of usage
[Holiday Usage Document](https://flarebrow.github.io/flaretool/flaretool.holiday.html#module-flaretool.holiday)
Support Range
![online](https://img.shields.io/endpoint?url=https%3A%2F%2Fpublic.flarebrow.com%2Fjapanholiday-badge.json?ver=2025)
```python
# オフライン版
from flaretool.holiday import JapaneseHolidays
# オンライン版
from flaretool.holiday import JapaneseHolidaysOnline
import datetime
# JapaneseHolidaysクラスのインスタンスを作成
holidays = JapaneseHolidays()
# オンライン版を使う場合はこちら
# holidays = JapaneseHolidaysOnline()
# 特定の日付が祝日かどうかを判定(date型)
date = datetime.date(2023, 1, 1)
is_holiday = holidays.get_holiday_name(date)
print(is_holiday) # "元日" が出力される
# 特定の日付が祝日かどうかを判定(str型)
date = "2023/1/1"
is_holiday = holidays.get_holiday_name(date)
print(is_holiday) # "元日" が出力される
# 特定の日付が祝日かどうかを判定(祝日ではない場合)
date = "2023/1/3"
is_holiday = holidays.get_holiday_name(date)
print(is_holiday) # None が出力される
# 特定の期間内の祝日一覧を取得
start_date = datetime.date(2023, 1, 1)
end_date = datetime.date(2023, 12, 31)
holiday_list = holidays.get_holidays_in_range(start_date, end_date)
for holiday in holiday_list:
print(holiday)
# 出力例:
# ("元日", datetime.date(2023, 1, 1))
# ("元日(振替休日)", datetime.date(2023, 1, 2))
# ("成人の日", datetime.date(2023, 1, 9))
# ("建国記念の日", datetime.date(2023, 2, 11))
# ...
# 2023年の祝日を取得
holiday_list = holidays.get_holidays("2023")
for holiday in holiday_list:
print(holiday)
# 出力例:
# ("元日", datetime.date(2023, 1, 1))
# ("元日(振替休日)", datetime.date(2023, 1, 2))
# ("成人の日", datetime.date(2023, 1, 9))
# ("建国記念の日", datetime.date(2023, 2, 11))
# ...
# 2023年5月の祝日を取得
holiday_list = holidays.get_holidays("202305")
for holiday in holiday_list:
print(holiday)
# 出力例:
# ('憲法記念日', datetime.date(2023, 5, 3))
# ('みどりの日', datetime.date(2023, 5, 4))
# ('こどもの日', datetime.date(2023, 5, 5))
# 営業日を取得(7月)
date = datetime.date(2023, 7, 1)
## 第1営業日を取得
business_day = holidays.get_first_business_day(date)
print(business_day) # "2023-07-03" が出力される
## 第4営業日を取得
business_day = holidays.get_first_business_day(date, 4)
print(business_day) # "2023-07-06" が出力される
## 最終営業日を取得
business_day = holidays.get_last_business_day(date)
print(business_day) # "2023-07-31" が出力される
# 特定期間内の営業日のリストを取得
business_days = holidays.get_business_date_range(start_date, end_date)
for business_day in business_days:
print(business_day)
# 出力例:
# 2023-01-03
# 2023-01-04
# 2023-01-05
# ...
```
## Decorator Examples of usage
[Decorator Usage Document](https://flarebrow.github.io/flaretool/flaretool.html#module-flaretool.decorators)
```python
from flaretool.errors import FlareToolNetworkError
from flaretool.decorators import network_required, retry, repeat, timeout, timer
# ネットワーク接続を必須とするデコレーター
@network_required
def network_access(url):
# ネットワークに接続されている場合に実行する処理
response = requests.get(url)
return response.json()
def main():
try:
network_access()
except FlareToolNetworkError:
# ネットワークに接続されていない場合の処理
pass
# 例外が発生した場合にリトライを行うデコレーター
@retry(tries=3, delay=2) # 2秒毎に3回までリトライ
# @retry(3) # ←この場合は1秒毎に3回までリトライ
def retry_function():
pass
# 複数回実行を行うデコレーター
@repeat(tries=3, interval=2) # 2秒毎に3回メソッドを実行
# @repeat(2) # ←この場合は連続で2回実行
def repeat_function():
# 強制的に実行を止めたい場合はStopIterationをraiseさせる
print("repeat message")
if 複数回の実行をとめたい条件:
raise StopIteration("Stop the loop!")
pass
## 出力例
# repeat message
# repeat message
# repeat message
# 制限時間をつけるデコレーター
@timeout(5)
def my_function():
# Some time-consuming operation
time.sleep(10)
return "Operation completed"
try:
result = my_function()
print(result)
except TimeoutError:
print("Operation timed out")
## 出力例
# Operation timed out
# メソッドの実行時間を計測するデコレーター
## Logger Setup
from flaretool.logger import setup_logger
logger = setup_logger(logging.DEBUG, console=True)
@timer
def example_function(x):
time.sleep(x)
return x
example_function(2)
## 出力例
# [2024-08-01 00:00:00,000] DEBUG : example_function took 2.0000 seconds to execute.
```
# Flarebrow Service
There are the following services available:
1. Short URL service: This service allows you to shorten URLs.
2. DDNS (Dynamic DNS) service: This service provides Dynamic DNS functionality.
To use this class, you need to set up an API key.
## Configuration API Key
The library you are using relies on an API key to communicate with an external service. To securely store the API key, it needs to be defined either as an environment variable or in a `.env` file or script setting. Please follow the instructions below:
### Using an script setting:
```python
import flaretool
flaretool.api_key = "your_api_key_here"
```
### Using an environment variable:
Set the API key as an environment variable using the following variable name:
- API_KEY
Example of defining an environment variable (Linux/macOS):
```bash
export API_KEY=your_api_key_here
```
Example of defining an environment variable (Windows):
```bat
set API_KEY=your_api_key_here
```
### Using a `.env` file:
Create a `.env` file in the root directory of your project and define the API key as follows:
```env
API_KEY=your_api_key_here
```
The library will read the API key from the `.env` file.
You need to log in to the external service's account to obtain an API key. Be careful not to share your API key with others, and avoid committing the `.env` file to a public version control system.
Please refer to the documentation of the library you are using to find the specific instructions for setting the API key and the exact name of the environment variable.
## ShortURL Service Usage
[ShortURL Usage Document](https://flarebrow.github.io/flaretool/flaretool.shorturl.html#module-flaretool.shorturl)
```python
from flaretool.shorturl import ShortUrlService
shorturl = ShortUrlService()
# 新規登録
result = shorturl.create_short_url("https://example.com")
print("ShortLink:", result.link) # https://○○○/○○○
print("OriginalURL:", result.url) # https://example.com
# 情報取得
result = shorturl.get_short_url_info_list(result.id)[0]
print("ShortLink:", result.link) # https://○○○/○○○
print("OriginalURL:", result.url) # https://example.com
# 更新
result.url = "https://example.com/sample"
result = shorturl.update_short_url(result)
print("ShortLink:", result.link) # https://○○○/○○○
print("OriginalURL:", result.url) # https://example.com/sample
# 削除
shorturl.delete_short_url(result)
# QRコード取得
image_data = shorturl.get_qr_code_raw_data(result)
image_path = "image.png"
with open(image_path, 'wb') as image_file:
image_file.write(image_data) # image.png にQRコード画像が保存されます
# ※ QRコードは(株)デンソーウェーブの登録商標です
```
## Dynamic DNS Service Usage
[Dynamic DNS Usage Document](https://flarebrow.github.io/flaretool/flaretool.ddns.html#module-flaretool.ddns)
```python
from flaretool.ddns import DdnsService
service = DdnsService()
info = service.update_ddns("example", "192.168.0.100")
print(info.status) # successful
print(info.currentIp) # 192.168.0.99
print(info.updateIp) # 192.168.0.100
print(info.domain) # example.○○○.○○
```
Raw data
{
"_id": null,
"home_page": "https://main.flarebrow.com",
"name": "flaretool",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "flaretool",
"author": "flarebrow",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/a0/de/72f754ffeaa90ad7a842efd734e61e2aea2e24646be204396c79ce71edc3/flaretool-0.2.5.tar.gz",
"platform": null,
"description": "# flaretool\n\n**flaretool** is flarebrow Library.\n\n![License](https://img.shields.io/github/license/flarebrow/flaretool)\n[![python](https://img.shields.io/badge/python-%3E%3D3.9-blue)](https://github.com/flarebrow/flaretool)\n[![version](https://img.shields.io/github/v/release/flarebrow/flaretool?include_prereleases)](https://github.com/flarebrow/flaretool/releases/latest)\n[![ReleaseDate](https://img.shields.io/github/release-date/flarebrow/flaretool)](https://github.com/flarebrow/flaretool/releases/latest)\n![build](https://img.shields.io/github/actions/workflow/status/flarebrow/flaretool/auto_test.yml)\n![Coverage](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/flarebrow/e31fc348a9dea0098de9540dc5961668/raw/pytest-coverage-3.9.json)\n[![Downloads](https://static.pepy.tech/badge/flaretool)](https://pepy.tech/project/flaretool)\n\n[API Doc](https://flarebrow.github.io/flaretool/)\n\n**Attention**\n\nThis library is under development and may exhibit unexpected behavior. New features will be released soon. Please stay tuned.\n\n## install\n```bash\npip install flaretool\n```\n\n## NetTool usage\n\n[NetTool Usage Document](https://flarebrow.github.io/flaretool/flaretool.nettool.html)\n\n\n### NetTool Examples of usage\n```python\nfrom flaretool import nettool\n\n# \u6307\u5b9a\u3055\u308c\u305fIP\u30a2\u30c9\u30ec\u30b9\u306e\u60c5\u5831\u3092\u53d6\u5f97\u3059\u308b\u4f8b\nip_info = nettool.get_global_ipaddr_info(\"192.168.0.1\")\nprint(\"ip:\", ip_info.ipaddr)\nprint(\"hostname:\", ip_info.hostname)\nprint(\"country:\", ip_info.country)\n# \u51fa\u529b\u4f8b\uff1a\n# ip: 192.168.0.1\n# hostname: example.com\n# country: earth\n\n# \u30c9\u30e1\u30a4\u30f3\u540d\u304b\u3089IP\u30a2\u30c9\u30ec\u30b9\u3092\u53d6\u5f97\u3059\u308b\u4f8b\nip_address = nettool.lookup_ip(\"example.com\")\nprint(ip_address) # 123.456.789.001\n\n# IP\u30a2\u30c9\u30ec\u30b9\u304b\u3089\u30c9\u30e1\u30a4\u30f3\u540d\u3092\u53d6\u5f97\u3059\u308b\u4f8b\ndomain_name = nettool.lookup_domain(\"1.1.1.1\")\nprint(domain_name) # one.one.one.one\n\n# \u6307\u5b9a\u3055\u308c\u305fIP\u30a2\u30c9\u30ec\u30b9\u304c\u6307\u5b9a\u3055\u308c\u305f\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u306b\u5c5e\u3057\u3066\u3044\u308b\u304b\u3069\u3046\u304b\u3092\u5224\u5b9a\u3059\u308b\u4f8b\nallowed_networks = [\"192.168.0.0/24\", \"10.0.0.0/16\"]\nis_allowed = nettool.is_ip_in_allowed_networks(\n \"192.168.0.100\", allowed_networks)\nprint(is_allowed) # True\n\n# \u6307\u5b9a\u3055\u308c\u305f\u30c9\u30e1\u30a4\u30f3\u540d\u304c\u5b58\u5728\u3059\u308b\u304b\u3069\u3046\u304b\u3092\u5224\u5b9a\u3059\u308b\u4f8b\ndomain_exists = nettool.domain_exists(\"example.com\")\nprint(domain_exists) # True\n\n# \u65e5\u672c\u306eIP\u30a2\u30c9\u30ec\u30b9\u306e\u30ea\u30b9\u30c8\u3092\u53d6\u5f97\u3059\u308b\u4f8b\njapan_ips = nettool.get_japanip_list()\nprint(japan_ips)\n\n# \u6307\u5b9a\u3055\u308c\u305f\u30a2\u30c9\u30ec\u30b9\u304c\u65e5\u672c\u306eIP\u30a2\u30c9\u30ec\u30b9\u304b\u78ba\u8a8d\u3059\u308b\u4f8b\nis_japan = nettool.is_japan_ip(\"203.0.113.1\")\nprint(is_japan) # False\n\n# \u65e5\u672c\u8a9e\u3092\u542b\u3080\u30c9\u30e1\u30a4\u30f3\u3092punycode\u306b\u5909\u63db\u3059\u308b\u4f8b\npuny_info = nettool.get_puny_code(\"\u65e5\u672c\u8a9e\u30c9\u30e1\u30a4\u30f3.jp\")\nprint(\"originalvalue:\", puny_info.originalvalue)\nprint(\"encodevalue:\", puny_info.encodevalue)\nprint(\"decodevalue:\", puny_info.decodevalue)\n# \u51fa\u529b\u4f8b\uff1a\n# originalvalue: \u65e5\u672c\u8a9e\u30c9\u30e1\u30a4\u30f3.jp\n# encodevalue: xn--eckwd4c7c5976acvb2w6i.jp\n# decodevalue: \u65e5\u672c\u8a9e\u30c9\u30e1\u30a4\u30f3.jp\n\n# \u7279\u5b9a\u306e\u30e6\u30fc\u30b6\u30fc\u30a8\u30fc\u30b8\u30a7\u30f3\u30c8\u3067\u30b9\u30af\u30ec\u30a4\u30d4\u30f3\u30b0\u53ef\u5426\u3092\u78ba\u8a8d\u3059\u308b\u4f8b\nurl = \"http://example.com/page.html\"\nuser_agent = \"MyScraperBot\"\nallowed = nettool.is_scraping_allowed(url, user_agent) # user_agent\u306f\u30aa\u30d7\u30b7\u30e7\u30f3\u5f15\u6570\nif allowed:\n print(f\"{url} \u306f\u30e6\u30fc\u30b6\u30fc\u30a8\u30fc\u30b8\u30a7\u30f3\u30c8 '{user_agent}' \u3067\u306e\u30b9\u30af\u30ec\u30a4\u30d4\u30f3\u30b0\u304c\u8a31\u53ef\u3055\u308c\u3066\u3044\u307e\u3059\u3002\")\nelse:\n print(f\"{url} \u306f\u30e6\u30fc\u30b6\u30fc\u30a8\u30fc\u30b8\u30a7\u30f3\u30c8 '{user_agent}' \u3067\u306e\u30b9\u30af\u30ec\u30a4\u30d4\u30f3\u30b0\u304c\u7981\u6b62\u3055\u308c\u3066\u3044\u307e\u3059\u3002\")\n```\n\n### NetTool Command Examples of usage\n\n```bash\nflaretool nettool get_global_ipaddr_info\n# usage\n# flaretool nettool {FunctionName} [args...]\n```\n\nAll methods within NetTool can be executed as commands.\n\n\n### Help Command\n\n```bash\nflaretool nettool -h\n```\n\n## String utills usage\n\n[String Utills Usage Document](https://flarebrow.github.io/flaretool/flaretool.html#module-flaretool.utills)\n\n```python\nfrom flaretool import utills\nfrom flaretool.utills import ConversionMode\n\n# \u6587\u5b57\u5217\u5909\u63db\n# \u534a\u89d2\nvalue = \"\uff11\uff12\uff13\uff14\uff15\uff16\uff17\uff18\uff19\uff16\uff17\uff18\uff19\"\nresult = utills.convert_value(value)\nprint(result) # \"1234567896789\"\n\n# \u5168\u89d2\nvalue = \"Hello\"\nresult = utills.convert_value(value, ConversionMode.FULL_WIDTH)\nprint(result) # \"\uff28\uff45\uff4c\uff4c\uff4f\"\n\n# \u6587\u5b57\u5217\u306e\u307f\u534a\u89d2\nvalue = \"\uff21\uff22\uff23\uff41\uff42\uff43\uff11\uff12\uff13\"\nresult = utills.convert_value(\n value, ascii=True, digit=False, kana=False)\nprint(result) # \"ABCabc\uff11\uff12\uff13\"\n\n# \u5c0f\u6587\u5b57\nvalue = \"ABCabc\"\nresult = utills.convert_value(\n value, ConversionMode.LOWER)\nprint(result) # \"abcabc\"\n\n# \u5927\u6587\u5b57\nvalue = \"ABCabc\"\nresult = utills.convert_value(\n value, ConversionMode.UPPER)\nprint(result) # \"ABCABC\"\n```\n\n## JapaneseHoliday Examples of usage\n\n[Holiday Usage Document](https://flarebrow.github.io/flaretool/flaretool.holiday.html#module-flaretool.holiday)\n\nSupport Range\n\n![online](https://img.shields.io/endpoint?url=https%3A%2F%2Fpublic.flarebrow.com%2Fjapanholiday-badge.json?ver=2025)\n\n```python\n# \u30aa\u30d5\u30e9\u30a4\u30f3\u7248\nfrom flaretool.holiday import JapaneseHolidays\n# \u30aa\u30f3\u30e9\u30a4\u30f3\u7248\nfrom flaretool.holiday import JapaneseHolidaysOnline\nimport datetime\n\n# JapaneseHolidays\u30af\u30e9\u30b9\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u4f5c\u6210\nholidays = JapaneseHolidays()\n# \u30aa\u30f3\u30e9\u30a4\u30f3\u7248\u3092\u4f7f\u3046\u5834\u5408\u306f\u3053\u3061\u3089\n# holidays = JapaneseHolidaysOnline()\n\n# \u7279\u5b9a\u306e\u65e5\u4ed8\u304c\u795d\u65e5\u304b\u3069\u3046\u304b\u3092\u5224\u5b9a(date\u578b)\ndate = datetime.date(2023, 1, 1)\nis_holiday = holidays.get_holiday_name(date)\nprint(is_holiday) # \"\u5143\u65e5\" \u304c\u51fa\u529b\u3055\u308c\u308b\n\n# \u7279\u5b9a\u306e\u65e5\u4ed8\u304c\u795d\u65e5\u304b\u3069\u3046\u304b\u3092\u5224\u5b9a(str\u578b)\ndate = \"2023/1/1\"\nis_holiday = holidays.get_holiday_name(date)\nprint(is_holiday) # \"\u5143\u65e5\" \u304c\u51fa\u529b\u3055\u308c\u308b\n\n# \u7279\u5b9a\u306e\u65e5\u4ed8\u304c\u795d\u65e5\u304b\u3069\u3046\u304b\u3092\u5224\u5b9a(\u795d\u65e5\u3067\u306f\u306a\u3044\u5834\u5408)\ndate = \"2023/1/3\"\nis_holiday = holidays.get_holiday_name(date)\nprint(is_holiday) # None \u304c\u51fa\u529b\u3055\u308c\u308b\n\n# \u7279\u5b9a\u306e\u671f\u9593\u5185\u306e\u795d\u65e5\u4e00\u89a7\u3092\u53d6\u5f97\nstart_date = datetime.date(2023, 1, 1)\nend_date = datetime.date(2023, 12, 31)\nholiday_list = holidays.get_holidays_in_range(start_date, end_date)\nfor holiday in holiday_list:\n print(holiday)\n# \u51fa\u529b\u4f8b:\n# (\"\u5143\u65e5\", datetime.date(2023, 1, 1))\n# (\"\u5143\u65e5\uff08\u632f\u66ff\u4f11\u65e5\uff09\", datetime.date(2023, 1, 2))\n# (\"\u6210\u4eba\u306e\u65e5\", datetime.date(2023, 1, 9))\n# (\"\u5efa\u56fd\u8a18\u5ff5\u306e\u65e5\", datetime.date(2023, 2, 11))\n# ...\n\n# 2023\u5e74\u306e\u795d\u65e5\u3092\u53d6\u5f97\nholiday_list = holidays.get_holidays(\"2023\")\nfor holiday in holiday_list:\n print(holiday)\n# \u51fa\u529b\u4f8b:\n# (\"\u5143\u65e5\", datetime.date(2023, 1, 1))\n# (\"\u5143\u65e5\uff08\u632f\u66ff\u4f11\u65e5\uff09\", datetime.date(2023, 1, 2))\n# (\"\u6210\u4eba\u306e\u65e5\", datetime.date(2023, 1, 9))\n# (\"\u5efa\u56fd\u8a18\u5ff5\u306e\u65e5\", datetime.date(2023, 2, 11))\n# ...\n\n# 2023\u5e745\u6708\u306e\u795d\u65e5\u3092\u53d6\u5f97\nholiday_list = holidays.get_holidays(\"202305\")\nfor holiday in holiday_list:\n print(holiday)\n# \u51fa\u529b\u4f8b:\n# ('\u61b2\u6cd5\u8a18\u5ff5\u65e5', datetime.date(2023, 5, 3))\n# ('\u307f\u3069\u308a\u306e\u65e5', datetime.date(2023, 5, 4))\n# ('\u3053\u3069\u3082\u306e\u65e5', datetime.date(2023, 5, 5))\n\n# \u55b6\u696d\u65e5\u3092\u53d6\u5f97(7\u6708)\ndate = datetime.date(2023, 7, 1)\n\n## \u7b2c1\u55b6\u696d\u65e5\u3092\u53d6\u5f97\nbusiness_day = holidays.get_first_business_day(date)\nprint(business_day) # \"2023-07-03\" \u304c\u51fa\u529b\u3055\u308c\u308b\n\n## \u7b2c4\u55b6\u696d\u65e5\u3092\u53d6\u5f97\nbusiness_day = holidays.get_first_business_day(date, 4)\nprint(business_day) # \"2023-07-06\" \u304c\u51fa\u529b\u3055\u308c\u308b\n\n## \u6700\u7d42\u55b6\u696d\u65e5\u3092\u53d6\u5f97\nbusiness_day = holidays.get_last_business_day(date)\nprint(business_day) # \"2023-07-31\" \u304c\u51fa\u529b\u3055\u308c\u308b\n\n# \u7279\u5b9a\u671f\u9593\u5185\u306e\u55b6\u696d\u65e5\u306e\u30ea\u30b9\u30c8\u3092\u53d6\u5f97\nbusiness_days = holidays.get_business_date_range(start_date, end_date)\nfor business_day in business_days:\n print(business_day)\n# \u51fa\u529b\u4f8b:\n# 2023-01-03\n# 2023-01-04\n# 2023-01-05\n# ...\n```\n\n## Decorator Examples of usage\n\n[Decorator Usage Document](https://flarebrow.github.io/flaretool/flaretool.html#module-flaretool.decorators)\n\n```python\nfrom flaretool.errors import FlareToolNetworkError\nfrom flaretool.decorators import network_required, retry, repeat, timeout, timer\n\n# \u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u63a5\u7d9a\u3092\u5fc5\u9808\u3068\u3059\u308b\u30c7\u30b3\u30ec\u30fc\u30bf\u30fc\n@network_required\ndef network_access(url):\n # \u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u306b\u63a5\u7d9a\u3055\u308c\u3066\u3044\u308b\u5834\u5408\u306b\u5b9f\u884c\u3059\u308b\u51e6\u7406\n response = requests.get(url)\n return response.json()\n\ndef main():\n try:\n network_access()\n except FlareToolNetworkError:\n # \u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u306b\u63a5\u7d9a\u3055\u308c\u3066\u3044\u306a\u3044\u5834\u5408\u306e\u51e6\u7406\n pass\n\n# \u4f8b\u5916\u304c\u767a\u751f\u3057\u305f\u5834\u5408\u306b\u30ea\u30c8\u30e9\u30a4\u3092\u884c\u3046\u30c7\u30b3\u30ec\u30fc\u30bf\u30fc\n@retry(tries=3, delay=2) # 2\u79d2\u6bce\u306b3\u56de\u307e\u3067\u30ea\u30c8\u30e9\u30a4\n# @retry(3) # \u2190\u3053\u306e\u5834\u5408\u306f1\u79d2\u6bce\u306b3\u56de\u307e\u3067\u30ea\u30c8\u30e9\u30a4\ndef retry_function():\n pass\n\n# \u8907\u6570\u56de\u5b9f\u884c\u3092\u884c\u3046\u30c7\u30b3\u30ec\u30fc\u30bf\u30fc\n@repeat(tries=3, interval=2) # 2\u79d2\u6bce\u306b3\u56de\u30e1\u30bd\u30c3\u30c9\u3092\u5b9f\u884c\n# @repeat(2) # \u2190\u3053\u306e\u5834\u5408\u306f\u9023\u7d9a\u30672\u56de\u5b9f\u884c\ndef repeat_function():\n # \u5f37\u5236\u7684\u306b\u5b9f\u884c\u3092\u6b62\u3081\u305f\u3044\u5834\u5408\u306fStopIteration\u3092raise\u3055\u305b\u308b\n print(\"repeat message\")\n if \u8907\u6570\u56de\u306e\u5b9f\u884c\u3092\u3068\u3081\u305f\u3044\u6761\u4ef6:\n raise StopIteration(\"Stop the loop!\")\n pass\n## \u51fa\u529b\u4f8b\n# repeat message\n# repeat message\n# repeat message\n\n# \u5236\u9650\u6642\u9593\u3092\u3064\u3051\u308b\u30c7\u30b3\u30ec\u30fc\u30bf\u30fc\n@timeout(5)\ndef my_function():\n # Some time-consuming operation\n time.sleep(10)\n return \"Operation completed\"\ntry:\n result = my_function()\n print(result)\nexcept TimeoutError:\n print(\"Operation timed out\")\n## \u51fa\u529b\u4f8b\n# Operation timed out\n\n# \u30e1\u30bd\u30c3\u30c9\u306e\u5b9f\u884c\u6642\u9593\u3092\u8a08\u6e2c\u3059\u308b\u30c7\u30b3\u30ec\u30fc\u30bf\u30fc\n## Logger Setup\nfrom flaretool.logger import setup_logger\nlogger = setup_logger(logging.DEBUG, console=True)\n@timer\ndef example_function(x):\n time.sleep(x)\n return x\n\nexample_function(2)\n## \u51fa\u529b\u4f8b\n# [2024-08-01 00:00:00,000] DEBUG : example_function took 2.0000 seconds to execute.\n```\n\n# Flarebrow Service\n\nThere are the following services available:\n\n1. Short URL service: This service allows you to shorten URLs.\n2. DDNS (Dynamic DNS) service: This service provides Dynamic DNS functionality.\n\nTo use this class, you need to set up an API key.\n\n## Configuration API Key\n\nThe library you are using relies on an API key to communicate with an external service. To securely store the API key, it needs to be defined either as an environment variable or in a `.env` file or script setting. Please follow the instructions below:\n\n### Using an script setting:\n\n```python\nimport flaretool\nflaretool.api_key = \"your_api_key_here\"\n```\n\n### Using an environment variable:\n Set the API key as an environment variable using the following variable name:\n - API_KEY\n\n Example of defining an environment variable (Linux/macOS):\n ```bash\n export API_KEY=your_api_key_here\n ```\n\n Example of defining an environment variable (Windows):\n ```bat\n set API_KEY=your_api_key_here\n ```\n\n### Using a `.env` file:\n Create a `.env` file in the root directory of your project and define the API key as follows:\n ```env\n API_KEY=your_api_key_here\n ```\n The library will read the API key from the `.env` file.\n\nYou need to log in to the external service's account to obtain an API key. Be careful not to share your API key with others, and avoid committing the `.env` file to a public version control system.\n\nPlease refer to the documentation of the library you are using to find the specific instructions for setting the API key and the exact name of the environment variable.\n\n## ShortURL Service Usage\n\n[ShortURL Usage Document](https://flarebrow.github.io/flaretool/flaretool.shorturl.html#module-flaretool.shorturl)\n\n```python\nfrom flaretool.shorturl import ShortUrlService\nshorturl = ShortUrlService()\n\n# \u65b0\u898f\u767b\u9332\nresult = shorturl.create_short_url(\"https://example.com\")\nprint(\"ShortLink:\", result.link) # https://\u25cb\u25cb\u25cb/\u25cb\u25cb\u25cb\nprint(\"OriginalURL:\", result.url) # https://example.com\n\n# \u60c5\u5831\u53d6\u5f97\nresult = shorturl.get_short_url_info_list(result.id)[0]\nprint(\"ShortLink:\", result.link) # https://\u25cb\u25cb\u25cb/\u25cb\u25cb\u25cb\nprint(\"OriginalURL:\", result.url) # https://example.com\n\n# \u66f4\u65b0\nresult.url = \"https://example.com/sample\"\nresult = shorturl.update_short_url(result)\nprint(\"ShortLink:\", result.link) # https://\u25cb\u25cb\u25cb/\u25cb\u25cb\u25cb\nprint(\"OriginalURL:\", result.url) # https://example.com/sample\n\n# \u524a\u9664\nshorturl.delete_short_url(result)\n\n# QR\u30b3\u30fc\u30c9\u53d6\u5f97\nimage_data = shorturl.get_qr_code_raw_data(result)\nimage_path = \"image.png\"\nwith open(image_path, 'wb') as image_file:\n image_file.write(image_data) # image.png \u306bQR\u30b3\u30fc\u30c9\u753b\u50cf\u304c\u4fdd\u5b58\u3055\u308c\u307e\u3059\n# \u203b QR\u30b3\u30fc\u30c9\u306f(\u682a)\u30c7\u30f3\u30bd\u30fc\u30a6\u30a7\u30fc\u30d6\u306e\u767b\u9332\u5546\u6a19\u3067\u3059\n```\n\n## Dynamic DNS Service Usage\n\n[Dynamic DNS Usage Document](https://flarebrow.github.io/flaretool/flaretool.ddns.html#module-flaretool.ddns)\n\n```python\nfrom flaretool.ddns import DdnsService\nservice = DdnsService()\ninfo = service.update_ddns(\"example\", \"192.168.0.100\")\nprint(info.status) # successful\nprint(info.currentIp) # 192.168.0.99\nprint(info.updateIp) # 192.168.0.100\nprint(info.domain) # example.\u25cb\u25cb\u25cb.\u25cb\u25cb\n```\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "this is flarebrow package",
"version": "0.2.5",
"project_urls": {
"Documentation": "https://flarebrow.github.io/flaretool/",
"Funding": "https://github.com/sponsors/flarebrow",
"Homepage": "https://main.flarebrow.com",
"Source": "https://github.com/flarebrow/flaretool"
},
"split_keywords": [
"flaretool"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "95ada672d1e0a7fa5798da04599bc35870a3ffdf0972530cfb080014e455a6e5",
"md5": "e0f5cce4fef3e94d80d88850a4ec2611",
"sha256": "ae7fc827e7bfc4df48717ac8e9546e012275c3666a3602e6cf02ec819c96f54e"
},
"downloads": -1,
"filename": "flaretool-0.2.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e0f5cce4fef3e94d80d88850a4ec2611",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 40394,
"upload_time": "2025-01-21T19:01:50",
"upload_time_iso_8601": "2025-01-21T19:01:50.432977Z",
"url": "https://files.pythonhosted.org/packages/95/ad/a672d1e0a7fa5798da04599bc35870a3ffdf0972530cfb080014e455a6e5/flaretool-0.2.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "a0de72f754ffeaa90ad7a842efd734e61e2aea2e24646be204396c79ce71edc3",
"md5": "f459ffd8371dc299e5cc7b0049027d8b",
"sha256": "ee7e3e23066d522c1afdd9f528b6eb330a8190cc5c1aa48f694d2675db32809d"
},
"downloads": -1,
"filename": "flaretool-0.2.5.tar.gz",
"has_sig": false,
"md5_digest": "f459ffd8371dc299e5cc7b0049027d8b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 37345,
"upload_time": "2025-01-21T19:01:52",
"upload_time_iso_8601": "2025-01-21T19:01:52.302107Z",
"url": "https://files.pythonhosted.org/packages/a0/de/72f754ffeaa90ad7a842efd734e61e2aea2e24646be204396c79ce71edc3/flaretool-0.2.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-21 19:01:52",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "sponsors",
"github_project": "flarebrow",
"github_not_found": true,
"lcname": "flaretool"
}