Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add stubs for python-cronlog #8917

Merged
merged 9 commits into from
Oct 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyrightconfig.stricter.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"stubs/paramiko",
"stubs/prettytable",
"stubs/protobuf",
"stubs/python-crontab",
"stubs/pytz/pytz/lazy.pyi",
"stubs/pytz/pytz/reference.pyi",
"stubs/pytz/pytz/tzfile.pyi",
Expand Down
1 change: 1 addition & 0 deletions stubs/python-crontab/METADATA.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version = "2.6.*"
32 changes: 32 additions & 0 deletions stubs/python-crontab/cronlog.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from _typeshed import Self, StrOrBytesPath
from codecs import StreamReaderWriter
from collections.abc import Generator, Iterator
from types import TracebackType

MATCHER: str

class LogReader:
filename: StrOrBytesPath
mass: int
size: int
read: int
pipe: StreamReaderWriter | None
def __init__(self, filename: StrOrBytesPath, mass: int = ...) -> None: ...
def __enter__(self: Self) -> Self: ...
def __exit__(
self, error_type: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
) -> None: ...
def __iter__(self) -> Iterator[str]: ...
def readlines(self, until: int = ...) -> Generator[tuple[int, str], None, None]: ...

class CronLog(LogReader):
user: str | None
def __init__(self, filename: StrOrBytesPath = ..., user: str | None = ...) -> None: ...
def for_program(self, command: str) -> ProgramLog: ...
def __iter__(self) -> dict[str, str | None]: ... # type: ignore[override]

class ProgramLog:
log: CronLog
command: str
def __init__(self, log: CronLog, command: str) -> None: ...
def __iter__(self) -> dict[str, str | None]: ...
233 changes: 233 additions & 0 deletions stubs/python-crontab/crontab.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,233 @@
import re
import subprocess
from _typeshed import Incomplete, Self
from collections import OrderedDict
from collections.abc import Callable, Generator
from logging import Logger
from types import TracebackType
from typing import Any

__pkgname__: str
ITEMREX: re.Pattern[str]
SPECREX: re.Pattern[str]
DEVNULL: str
WEEK_ENUM: list[str]
MONTH_ENUM: list[str | None]
SPECIALS: dict[str, str]
SPECIAL_IGNORE: list[str]
S_INFO: list[dict[str, Any]]
PY3: bool
WINOS: bool
POSIX: bool
SYSTEMV: bool
ZERO_PAD: bool
LOG: Logger
CRON_COMMAND: str
SHELL: str
current_user: Callable[[], str | None]

def open_pipe(cmd: str, *args: str, **flags) -> subprocess.Popen[Any]: ...

class CronTab:
lines: Incomplete
crons: Incomplete
filen: Incomplete
cron_command: Incomplete
env: Incomplete
root: bool
intab: Incomplete
def __init__(
self,
user: bool | str | None = ...,
tab: Incomplete | None = ...,
tabfile: Incomplete | None = ...,
log: Incomplete | None = ...,
) -> None: ...
def __enter__(self: Self) -> Self: ...
def __exit__(
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> None: ...
@property
def log(self): ...
@property
def user(self) -> str | None: ...
@property
def user_opt(self): ...
def read(self, filename: Incomplete | None = ...) -> None: ...
def append(self, item, line: str = ..., read: bool = ...) -> None: ...
def write(self, filename: Incomplete | None = ..., user: Incomplete | None = ..., errors: bool = ...) -> None: ...
def write_to_user(self, user: bool = ...): ...
def run_pending(self, **kwargs) -> Generator[Incomplete, None, None]: ...
def run_scheduler(self, timeout: int = ..., **kwargs) -> Generator[Incomplete, None, None]: ...
def render(self, errors: bool = ..., specials: bool = ...): ...
def new(self, command: str = ..., comment: str = ..., user: Incomplete | None = ..., pre_comment: bool = ...) -> CronItem: ...
def find_command(self, command) -> Generator[Incomplete, None, None]: ...
def find_comment(self, comment) -> Generator[Incomplete, None, None]: ...
def find_time(self, *args) -> Generator[Incomplete, None, None]: ...
@property
def commands(self) -> Generator[Incomplete, None, None]: ...
@property
def comments(self) -> Generator[Incomplete, None, None]: ...
def remove_all(self, *args, **kwargs): ...
def remove(self, *items): ...
def __iter__(self): ...
def __getitem__(self, i): ...
def __unicode__(self) -> str: ...
def __len__(self) -> int: ...

class CronItem:
cron: Incomplete
user: Incomplete
valid: bool
enabled: bool
special: bool
comment: Incomplete
command: Incomplete
last_run: Incomplete
env: Incomplete
pre_comment: bool
marker: Incomplete
stdin: Incomplete
slices: Incomplete
def __init__(
self, command: str = ..., comment: str = ..., user: Incomplete | None = ..., pre_comment: bool = ...
) -> None: ...
def __hash__(self) -> int: ...
def __eq__(self, other: object) -> bool: ...
@classmethod
def from_line(cls: type[Self], line: str, user: Incomplete | None = ..., cron: Incomplete | None = ...) -> Self: ...
def delete(self) -> None: ...
def set_command(self, cmd: str, parse_stdin: bool = ...) -> None: ...
def set_comment(self, cmt: str, pre_comment: bool = ...) -> None: ...
def parse(self, line) -> None: ...
def enable(self, enabled: bool = ...) -> bool: ...
def is_enabled(self) -> bool: ...
def is_valid(self) -> bool: ...
def render(self, specials: bool = ...) -> str: ...
def every_reboot(self): ...
def every(self, unit: int = ...): ...
def setall(self, *args: Any): ...
def clear(self): ...
def frequency(self, year: Incomplete | None = ...): ...
def frequency_per_year(self, year: Incomplete | None = ...): ...
def frequency_per_day(self): ...
def frequency_per_hour(self): ...
def run_pending(self, now: Incomplete | None = ...): ...
def run(self): ...
def schedule(self, date_from: Incomplete | None = ...): ...
def description(self, **kw: Any): ...
@property
def log(self): ...
@property
def minute(self): ...
@property
def minutes(self): ...
@property
def hour(self): ...
@property
def hours(self): ...
@property
def day(self): ...
@property
def dom(self): ...
@property
def month(self): ...
@property
def months(self): ...
@property
def dow(self): ...
def __len__(self) -> int: ...
def __getitem__(self, key: str): ...
def __lt__(self, value): ...
def __gt__(self, value): ...
def __unicode__(self) -> str: ...

class Every:
slices: Incomplete
unit: Incomplete
def __init__(self, item, units) -> None: ...
def set_attr(self, target: int) -> Callable[[], None]: ...
def year(self) -> None: ...

class CronSlices(list[CronSlice]):
special: Incomplete
def __init__(self, *args: Any) -> None: ...
def is_self_valid(self, *args: Any) -> bool: ...
@classmethod
def is_valid(cls, *args: Any) -> bool: ...
def setall(self, *slices) -> None: ...
def clean_render(self) -> str: ...
def render(self, specials: bool = ...) -> str: ...
def clear(self) -> None: ...
def frequency(self, year: Incomplete | None = ...): ...
def frequency_per_year(self, year: Incomplete | None = ...): ...
def frequency_per_day(self): ...
def frequency_per_hour(self): ...
def __eq__(self, arg: object) -> bool: ...

class SundayError(KeyError): ...

class Also:
obj: Incomplete
def __init__(self, obj) -> None: ...
def every(self, *a): ...
def on(self, *a): ...
def during(self, *a): ...

class CronSlice:
min: Incomplete
max: Incomplete
name: Incomplete
enum: Incomplete
parts: Incomplete
def __init__(self, info, value: Incomplete | None = ...) -> None: ...
def __hash__(self) -> int: ...
def parse(self, value) -> None: ...
def render(self, resolve: bool = ..., specials: bool = ...): ...
def __eq__(self, arg: object) -> bool: ...
def __unicode__(self) -> str: ...
def every(self, n_value, also: bool = ...): ...
def on(self, *n_value, **opts): ...
def during(self, vfrom, vto, also: bool = ...): ...
@property
def also(self): ...
def clear(self) -> None: ...
def get_range(self, *vrange): ...
def __iter__(self): ...
def __len__(self) -> int: ...
def parse_value(self, val, sunday: Incomplete | None = ...): ...

def get_cronvalue(value, enums): ...

class CronValue:
text: Incomplete
value: Incomplete
def __init__(self, value, enums) -> None: ...
def __lt__(self, value): ...
def __int__(self) -> int: ...

class CronRange:
dangling: Incomplete
slice: Incomplete
cron: Incomplete
seq: int
def __init__(self, vslice, *vrange) -> None: ...
vfrom: Incomplete
vto: Incomplete
def parse(self, value) -> None: ...
def all(self) -> None: ...
def render(self, resolve: bool = ...): ...
def range(self): ...
def every(self, value) -> None: ...
def __lt__(self, value): ...
def __gt__(self, value): ...
def __int__(self) -> int: ...
def __unicode__(self) -> str: ...

class OrderedVariableList(OrderedDict[Incomplete, Incomplete]):
job: Incomplete
def __init__(self, *args: Any, **kw: Any) -> None: ...
@property
def previous(self): ...
def all(self): ...
def __getitem__(self, key): ...
25 changes: 25 additions & 0 deletions stubs/python-crontab/crontabs.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from typing import Any

from crontab import CronTab

class UserSpool(list[CronTab]):
def __init__(self, loc: str, tabs: CronTabs | None = ...) -> None: ...
def listdir(self, loc: str) -> list[str]: ...
def get_owner(self, path: str) -> str: ...
def generate(self, loc: str, username: str) -> CronTab: ...

class SystemTab(list[CronTab]):
def __init__(self, loc: str, tabs: CronTabs | None = ...) -> None: ...

class AnaCronTab(list[CronTab]):
def __init__(self, loc: str, tabs: CronTabs | None = ...) -> None: ...
def add(self, loc: str, item: str, anajob) -> CronTab: ...

KNOWN_LOCATIONS: list[tuple[UserSpool | SystemTab | AnaCronTab, str]]

class CronTabs(list[UserSpool | SystemTab | AnaCronTab]):
def __new__(cls, *args: Any, **kw: Any): ...
def __init__(self) -> None: ...
def add(self, cls: type[UserSpool | SystemTab | AnaCronTab], *args: Any) -> None: ...
@property
def all(self) -> CronTab: ...