-
Notifications
You must be signed in to change notification settings - Fork 0
Home
write-pypistat makes it easy to collect, filter and save pypi statistics to csv files.
WritePypiStat
's constructor has two parameter:
-
package
:str
name of the target pypi package -
outdir
:str
, optional
path of the directory where the gathered data will be saved into csv files (default None)
In these examples we initilaize a WritePypiStat
class in order to collect statistics about pypistats
pypi package.
Because outdir
is None
the gathered statistics will be only printed to the console.
from writepypistat import WritePypiStat
write_pypistat = WritePypiStat("pypistats")
Because outdir
is not None
the gathered statistics will be saved into csv files too.
from writepypistat import WritePypiStat
write_pypistat = WritePypiStat("pypistats", "stats/pypistat")
WritePypiStat
has three property:
-
outdir
:str
, optional
path of the directory where the gathered data will be saved into csv files (default None) -
merge_stored_data
:bool
, optional
flag used to merge actual pypi statistics with previously stored (defaultTrue
) -
drop_percent_column
:bool
, optional
flag used to drop percent column (derived) from pypi statistics (defaultTrue
) -
drop_total_row
:bool
, optional
flag used to drop total row (derived) from pypi statistics (defaultTrue
)
outdir
can be changed or set at anytime.
from writepypistat import WritePypiStat
write_pypistat = WritePypiStat("pypistats")
write_pypistat.outdir = "stats/pypistat"
from writepypistat import WritePypiStat
write_pypistat = WritePypiStat("pypistats")
write_pypistat.merge_stored_data= False
from writepypistat import WritePypiStat
write_pypistat = WritePypiStat("pypistats")
write_pypistat.drop_percent_column= False
from writepypistat import WritePypiStat
write_pypistat = WritePypiStat("pypistats")
write_pypistat.drop_total_row= False
WritePypiStat
has two public methods.
Returns the specified pypi statistics.
Args:
-
stat_type
:enum
type of the statistics
(overall
,python_major
,python_minor
,system
) -
start_date
:str
, optional start date of the statistics, should be in one of the following formats:-
%Y
, for example2022
which means to be collected from2022-01-01
-
%Y-%m
, for example2022-01
which means to be collected from2022-01-01
-
%Y-%m-%d
, for example2022-01-01
which means to be collected from2022-01-01
-
None
which means to be collected from the last available date
default (None
)
-
-
end_date
:str
, optional end date of the statistics, should be in one of the following formats:-
%Y
, for example2022
which means to be collected until2022-12-31
-
%Y-%m
, for example2022-12
which means to be collected until2022-12-31
-
%Y-%m-%d
, for example2022-12-31
which means to be collected until2022-12-31
-
None
which means to be collected until the actual day
default (None
)
-
from writepypistat import WritePypiStat
write_pypistat = WritePypiStat("pypistats")
stats = write_pypistat.get_pypistat("overall", "2022-03", "2022-04-10")
Writes the specified pypi statistics.
Args:
-
stat_type
:enum
type of the statistics
(overall
,python_major
,python_minor
,system
) -
date_period
:enum
grouping of the statistics
(day
,month
,year
,None
)
default (None
) -
start_date
:str
, optional start date of the statistics, should be in one of the following formats:-
%Y
, for example2022
which means to be collected from2022-01-01
-
%Y-%m
, for example2022-01
which means to be collected from2022-01-01
-
%Y-%m-%d
, for example2022-01-01
which means to be collected from2022-01-01
-
None
which means to be collected from the last available date
default (None
)
-
-
end_date
:str
, optional end date of the statistics, should be in one of the following formats:-
%Y
, for example2022
which means to be collected until2022-12-31
-
%Y-%m
, for example2022-12
which means to be collected until2022-12-31
-
%Y-%m-%d
, for example2022-12-31
which means to be collected until2022-12-31
-
None
which means to be collected until the actual day
default (None
)
-
from writepypistat import WritePypiStat
write_pypistat = WritePypiStat("pypistats")
write_pypistat.write_pypistat("system", "month", "2022", "2022-03")