Skip to content

Commit a9236f9

Browse files
kasiumJelleZijlstraAlexWaygood
authored
Add stubs for python-cronlog (#8917)
Co-authored-by: Jelle Zijlstra <[email protected]> Co-authored-by: Alex Waygood <[email protected]>
1 parent de68029 commit a9236f9

File tree

5 files changed

+292
-0
lines changed

5 files changed

+292
-0
lines changed

pyrightconfig.stricter.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
"stubs/paramiko",
6363
"stubs/prettytable",
6464
"stubs/protobuf",
65+
"stubs/python-crontab",
6566
"stubs/pytz/pytz/lazy.pyi",
6667
"stubs/pytz/pytz/reference.pyi",
6768
"stubs/pytz/pytz/tzfile.pyi",

stubs/python-crontab/METADATA.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
version = "2.6.*"

stubs/python-crontab/cronlog.pyi

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
from _typeshed import Self, StrOrBytesPath
2+
from codecs import StreamReaderWriter
3+
from collections.abc import Generator, Iterator
4+
from types import TracebackType
5+
6+
MATCHER: str
7+
8+
class LogReader:
9+
filename: StrOrBytesPath
10+
mass: int
11+
size: int
12+
read: int
13+
pipe: StreamReaderWriter | None
14+
def __init__(self, filename: StrOrBytesPath, mass: int = ...) -> None: ...
15+
def __enter__(self: Self) -> Self: ...
16+
def __exit__(
17+
self, error_type: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
18+
) -> None: ...
19+
def __iter__(self) -> Iterator[str]: ...
20+
def readlines(self, until: int = ...) -> Generator[tuple[int, str], None, None]: ...
21+
22+
class CronLog(LogReader):
23+
user: str | None
24+
def __init__(self, filename: StrOrBytesPath = ..., user: str | None = ...) -> None: ...
25+
def for_program(self, command: str) -> ProgramLog: ...
26+
def __iter__(self) -> dict[str, str | None]: ... # type: ignore[override]
27+
28+
class ProgramLog:
29+
log: CronLog
30+
command: str
31+
def __init__(self, log: CronLog, command: str) -> None: ...
32+
def __iter__(self) -> dict[str, str | None]: ...

stubs/python-crontab/crontab.pyi

Lines changed: 233 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,233 @@
1+
import re
2+
import subprocess
3+
from _typeshed import Incomplete, Self
4+
from collections import OrderedDict
5+
from collections.abc import Callable, Generator
6+
from logging import Logger
7+
from types import TracebackType
8+
from typing import Any
9+
10+
__pkgname__: str
11+
ITEMREX: re.Pattern[str]
12+
SPECREX: re.Pattern[str]
13+
DEVNULL: str
14+
WEEK_ENUM: list[str]
15+
MONTH_ENUM: list[str | None]
16+
SPECIALS: dict[str, str]
17+
SPECIAL_IGNORE: list[str]
18+
S_INFO: list[dict[str, Any]]
19+
PY3: bool
20+
WINOS: bool
21+
POSIX: bool
22+
SYSTEMV: bool
23+
ZERO_PAD: bool
24+
LOG: Logger
25+
CRON_COMMAND: str
26+
SHELL: str
27+
current_user: Callable[[], str | None]
28+
29+
def open_pipe(cmd: str, *args: str, **flags) -> subprocess.Popen[Any]: ...
30+
31+
class CronTab:
32+
lines: Incomplete
33+
crons: Incomplete
34+
filen: Incomplete
35+
cron_command: Incomplete
36+
env: Incomplete
37+
root: bool
38+
intab: Incomplete
39+
def __init__(
40+
self,
41+
user: bool | str | None = ...,
42+
tab: Incomplete | None = ...,
43+
tabfile: Incomplete | None = ...,
44+
log: Incomplete | None = ...,
45+
) -> None: ...
46+
def __enter__(self: Self) -> Self: ...
47+
def __exit__(
48+
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
49+
) -> None: ...
50+
@property
51+
def log(self): ...
52+
@property
53+
def user(self) -> str | None: ...
54+
@property
55+
def user_opt(self): ...
56+
def read(self, filename: Incomplete | None = ...) -> None: ...
57+
def append(self, item, line: str = ..., read: bool = ...) -> None: ...
58+
def write(self, filename: Incomplete | None = ..., user: Incomplete | None = ..., errors: bool = ...) -> None: ...
59+
def write_to_user(self, user: bool = ...): ...
60+
def run_pending(self, **kwargs) -> Generator[Incomplete, None, None]: ...
61+
def run_scheduler(self, timeout: int = ..., **kwargs) -> Generator[Incomplete, None, None]: ...
62+
def render(self, errors: bool = ..., specials: bool = ...): ...
63+
def new(self, command: str = ..., comment: str = ..., user: Incomplete | None = ..., pre_comment: bool = ...) -> CronItem: ...
64+
def find_command(self, command) -> Generator[Incomplete, None, None]: ...
65+
def find_comment(self, comment) -> Generator[Incomplete, None, None]: ...
66+
def find_time(self, *args) -> Generator[Incomplete, None, None]: ...
67+
@property
68+
def commands(self) -> Generator[Incomplete, None, None]: ...
69+
@property
70+
def comments(self) -> Generator[Incomplete, None, None]: ...
71+
def remove_all(self, *args, **kwargs): ...
72+
def remove(self, *items): ...
73+
def __iter__(self): ...
74+
def __getitem__(self, i): ...
75+
def __unicode__(self) -> str: ...
76+
def __len__(self) -> int: ...
77+
78+
class CronItem:
79+
cron: Incomplete
80+
user: Incomplete
81+
valid: bool
82+
enabled: bool
83+
special: bool
84+
comment: Incomplete
85+
command: Incomplete
86+
last_run: Incomplete
87+
env: Incomplete
88+
pre_comment: bool
89+
marker: Incomplete
90+
stdin: Incomplete
91+
slices: Incomplete
92+
def __init__(
93+
self, command: str = ..., comment: str = ..., user: Incomplete | None = ..., pre_comment: bool = ...
94+
) -> None: ...
95+
def __hash__(self) -> int: ...
96+
def __eq__(self, other: object) -> bool: ...
97+
@classmethod
98+
def from_line(cls: type[Self], line: str, user: Incomplete | None = ..., cron: Incomplete | None = ...) -> Self: ...
99+
def delete(self) -> None: ...
100+
def set_command(self, cmd: str, parse_stdin: bool = ...) -> None: ...
101+
def set_comment(self, cmt: str, pre_comment: bool = ...) -> None: ...
102+
def parse(self, line) -> None: ...
103+
def enable(self, enabled: bool = ...) -> bool: ...
104+
def is_enabled(self) -> bool: ...
105+
def is_valid(self) -> bool: ...
106+
def render(self, specials: bool = ...) -> str: ...
107+
def every_reboot(self): ...
108+
def every(self, unit: int = ...): ...
109+
def setall(self, *args: Any): ...
110+
def clear(self): ...
111+
def frequency(self, year: Incomplete | None = ...): ...
112+
def frequency_per_year(self, year: Incomplete | None = ...): ...
113+
def frequency_per_day(self): ...
114+
def frequency_per_hour(self): ...
115+
def run_pending(self, now: Incomplete | None = ...): ...
116+
def run(self): ...
117+
def schedule(self, date_from: Incomplete | None = ...): ...
118+
def description(self, **kw: Any): ...
119+
@property
120+
def log(self): ...
121+
@property
122+
def minute(self): ...
123+
@property
124+
def minutes(self): ...
125+
@property
126+
def hour(self): ...
127+
@property
128+
def hours(self): ...
129+
@property
130+
def day(self): ...
131+
@property
132+
def dom(self): ...
133+
@property
134+
def month(self): ...
135+
@property
136+
def months(self): ...
137+
@property
138+
def dow(self): ...
139+
def __len__(self) -> int: ...
140+
def __getitem__(self, key: str): ...
141+
def __lt__(self, value): ...
142+
def __gt__(self, value): ...
143+
def __unicode__(self) -> str: ...
144+
145+
class Every:
146+
slices: Incomplete
147+
unit: Incomplete
148+
def __init__(self, item, units) -> None: ...
149+
def set_attr(self, target: int) -> Callable[[], None]: ...
150+
def year(self) -> None: ...
151+
152+
class CronSlices(list[CronSlice]):
153+
special: Incomplete
154+
def __init__(self, *args: Any) -> None: ...
155+
def is_self_valid(self, *args: Any) -> bool: ...
156+
@classmethod
157+
def is_valid(cls, *args: Any) -> bool: ...
158+
def setall(self, *slices) -> None: ...
159+
def clean_render(self) -> str: ...
160+
def render(self, specials: bool = ...) -> str: ...
161+
def clear(self) -> None: ...
162+
def frequency(self, year: Incomplete | None = ...): ...
163+
def frequency_per_year(self, year: Incomplete | None = ...): ...
164+
def frequency_per_day(self): ...
165+
def frequency_per_hour(self): ...
166+
def __eq__(self, arg: object) -> bool: ...
167+
168+
class SundayError(KeyError): ...
169+
170+
class Also:
171+
obj: Incomplete
172+
def __init__(self, obj) -> None: ...
173+
def every(self, *a): ...
174+
def on(self, *a): ...
175+
def during(self, *a): ...
176+
177+
class CronSlice:
178+
min: Incomplete
179+
max: Incomplete
180+
name: Incomplete
181+
enum: Incomplete
182+
parts: Incomplete
183+
def __init__(self, info, value: Incomplete | None = ...) -> None: ...
184+
def __hash__(self) -> int: ...
185+
def parse(self, value) -> None: ...
186+
def render(self, resolve: bool = ..., specials: bool = ...): ...
187+
def __eq__(self, arg: object) -> bool: ...
188+
def __unicode__(self) -> str: ...
189+
def every(self, n_value, also: bool = ...): ...
190+
def on(self, *n_value, **opts): ...
191+
def during(self, vfrom, vto, also: bool = ...): ...
192+
@property
193+
def also(self): ...
194+
def clear(self) -> None: ...
195+
def get_range(self, *vrange): ...
196+
def __iter__(self): ...
197+
def __len__(self) -> int: ...
198+
def parse_value(self, val, sunday: Incomplete | None = ...): ...
199+
200+
def get_cronvalue(value, enums): ...
201+
202+
class CronValue:
203+
text: Incomplete
204+
value: Incomplete
205+
def __init__(self, value, enums) -> None: ...
206+
def __lt__(self, value): ...
207+
def __int__(self) -> int: ...
208+
209+
class CronRange:
210+
dangling: Incomplete
211+
slice: Incomplete
212+
cron: Incomplete
213+
seq: int
214+
def __init__(self, vslice, *vrange) -> None: ...
215+
vfrom: Incomplete
216+
vto: Incomplete
217+
def parse(self, value) -> None: ...
218+
def all(self) -> None: ...
219+
def render(self, resolve: bool = ...): ...
220+
def range(self): ...
221+
def every(self, value) -> None: ...
222+
def __lt__(self, value): ...
223+
def __gt__(self, value): ...
224+
def __int__(self) -> int: ...
225+
def __unicode__(self) -> str: ...
226+
227+
class OrderedVariableList(OrderedDict[Incomplete, Incomplete]):
228+
job: Incomplete
229+
def __init__(self, *args: Any, **kw: Any) -> None: ...
230+
@property
231+
def previous(self): ...
232+
def all(self): ...
233+
def __getitem__(self, key): ...

stubs/python-crontab/crontabs.pyi

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from typing import Any
2+
3+
from crontab import CronTab
4+
5+
class UserSpool(list[CronTab]):
6+
def __init__(self, loc: str, tabs: CronTabs | None = ...) -> None: ...
7+
def listdir(self, loc: str) -> list[str]: ...
8+
def get_owner(self, path: str) -> str: ...
9+
def generate(self, loc: str, username: str) -> CronTab: ...
10+
11+
class SystemTab(list[CronTab]):
12+
def __init__(self, loc: str, tabs: CronTabs | None = ...) -> None: ...
13+
14+
class AnaCronTab(list[CronTab]):
15+
def __init__(self, loc: str, tabs: CronTabs | None = ...) -> None: ...
16+
def add(self, loc: str, item: str, anajob) -> CronTab: ...
17+
18+
KNOWN_LOCATIONS: list[tuple[UserSpool | SystemTab | AnaCronTab, str]]
19+
20+
class CronTabs(list[UserSpool | SystemTab | AnaCronTab]):
21+
def __new__(cls, *args: Any, **kw: Any): ...
22+
def __init__(self) -> None: ...
23+
def add(self, cls: type[UserSpool | SystemTab | AnaCronTab], *args: Any) -> None: ...
24+
@property
25+
def all(self) -> CronTab: ...

0 commit comments

Comments
 (0)