Skip to main content

The Python Package Index Project

Project description

About

The Python Package Index Project (pypipr)

pypi : https://pypi.org/project/pypipr

Setup

Install with pip

python -m pip install pypipr

Import with * for fastest access

from pypipr.pypipr import *

Test with

Pypipr.test_print()

Pypipr Class

test_print() memastikan module sudah terinstal dan dapat dijalankan

Pypipr.test_print()

functions

sets_ordered() Hanya mengambil nilai unik dari suatu list

array = [2, 3, 12, 3, 3, 42, 42, 1, 43, 2, 42, 41, 4, 24, 32, 42, 3, 12, 32, 42, 42]
print([i for i in sets_ordered(array)])

list_unique() sama seperti sets_ordered()

array = [2, 3, 12, 3, 3, 42, 42, 1, 43, 2, 42, 41, 4, 24, 32, 42, 3, 12, 32, 42, 42]
print([i for i in list_unique(array)])

chunck_array() membagi array menjadi potongan dengan besaran yg diinginkan

array = [2, 3, 12, 3, 3, 42, 42, 1, 43, 2, 42, 41, 4, 24, 32, 42, 3, 12, 32, 42, 42]
print([i for i in chunck_array(array, 5)])

print_colorize() print ke console dengan warna

print_colorize("Print some text")

@Log() / Log decorator akan melakukan print ke console. Mempermudah pembuatan log karena tidak perlu mengubah fungsi yg sudah ada. Berguna untuk memberikan informasi proses program yg sedang berjalan.

@log("Calling some function")
def some_function():
    ...
    return

print_log akan melakukan print ke console. Berguna untuk memberikan informasi proses program yg sedang berjalan.

print_log("Standalone Log")

input_char() meminta masukan satu huruf tanpa menekan enter. Char tidak ditampilkan.

input_char("Input Char without print : ")

input_char() meminta masukan satu huruf tanpa menekan enter. Char ditampilkan.

input_char_echo("Input Char n : ")

datetime_now() memudahkan dalam membuat tanggal dan waktu untuk suatu timezone

datetime_now("Asia/Jakarta")
datetime_now("GMT")
datetime_now("Etc/GMT+7")

WINDOWS True apabila berjalan di platform Windows

print(WINDOWS)

LINUX True apabila berjalan di platform Linux

print(LINUX)

file_put_contents() membuat file kemudian menuliskan contents ke file. Apabila file memiliki contents, maka contents akan di overwrite.

file_put_contents("ifile_test.txt", "Contoh menulis content")

file_get_contents() membaca contents file ke memory.

print(file_get_contents("ifile_test.txt"))

create_folder() membuat folder secara recursive.

create_folder("contoh_membuat_folder")
create_folder("contoh/membuat/folder/recursive")
create_folder("./contoh_membuat_folder/secara/recursive")

iscandir() scan folder, subfolder, dan file

for i in iscandir():
    print(i)

scan_folder() scan folder dan subfolder

for i in scan_folder():
    print(i)

scan_file() scan file dalam folder dan subfolder

for i in scan_file():
    print(i)

regex_multiple_replace() Melakukan multiple replacement untuk setiap list regex.

regex_replacement_list = [
    {"regex": r"\{\{\s*ini\s*\}\}", "replacement": "itu"},
    {"regex": r"\{\{\s*sini\s*\}\}", "replacement": "situ"},
]
data = "{{ ini }} adalah ini. {{sini}} berarti kesini."
data = regex_multiple_replace(data, regex_replacement_list)
print(data)

github_push() simple github push

github_push()

github_pull() simple github pull

github_pull()

html_get_contents() Mengambil content html dari url

# Using XPATH
a = html_get_contents("https://google.com/", xpath="//a")
for i in a:
    print(i.text)
    print(i.attrib.get('href'))

# Using REGEX
a = html_get_contents("https://google.com/", regex=r"(<a.[^>]+>(?:(?:\s+)?(.[^<]+)(?:\s+)?)<\/a>)")
for i in a:
    print(i)

# Using cssselect
a = html_get_contents("https://google.com/", css_select="a")
for i in a:
    print(i.text)
    print(i.attrib.get('href'))

get_filesize() Mengambil informasi file size dalam bytes

print(get_filesize(__file__))

get_filemtime() Mengambil informasi last modification time file dalam nano seconds

print(get_filemtime(__file__))

datetime_from_string() Mengubah human datetime string menjadi python standard datetime. Masih memerlukan perbaikan dan peningkatan. Kode yg di comment masih belum dapat dikenali. Yg belum dapat dikenali:

  • AM/PM
  • Kata yg berupa angka berdiri sendiri, karena ambigu antara tahun/bulan/tanggal/jam/menit/detik/mikrodetik
  • Timezone info
print(datetime_from_string("13-10-1993"))
print(datetime_from_string("1-Jan-2001"))
print(datetime_from_string("5-5-5"))
print(datetime_from_string("12:56 31-10-2022"))
# print(datetime_from_string("12:56 PM 31-10-2022"))
# print(datetime_from_string("2022 13 10"))
# print(datetime_from_string("11:59 Monday, October 31, 2022 (GMT+7)"))
print(datetime_from_string("oct 1"))
print(datetime_from_string("10:50"))
print(datetime_from_string("10:50:22"))
print(datetime_from_string("10:50", default_year=2022))
print(datetime_from_string("10:50", overwrite={"hour": 21}))

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pypipr-0.1.36.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pypipr-0.1.36-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file pypipr-0.1.36.tar.gz.

File metadata

  • Download URL: pypipr-0.1.36.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.10.7 Windows/10

File hashes

Hashes for pypipr-0.1.36.tar.gz
Algorithm Hash digest
SHA256 5c1e3fe1be996bb90017fff8baceff994f97de3c6a8dac6853554fe45ba41ef1
MD5 77acc23e8e31b9bb5e0fa499b92d123c
BLAKE2b-256 ee15131d326b1790c9da2fcb5a979fa3af6da4717e31713f725ac25d610d4179

See more details on using hashes here.

File details

Details for the file pypipr-0.1.36-py3-none-any.whl.

File metadata

  • Download URL: pypipr-0.1.36-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.10.7 Windows/10

File hashes

Hashes for pypipr-0.1.36-py3-none-any.whl
Algorithm Hash digest
SHA256 911f57c47511a0149c03ac9fe52b3287ba311c0b287f2c1735dfe47064cedc7e
MD5 e15fb655ea8f13579a9228eafc55812c
BLAKE2b-256 e90d1bb9afb3553088a1a7eca9c36afac4afa4b9098b5b652916357d52be2996

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page