hexsha string | size int64 | ext string | lang string | max_stars_repo_path string | max_stars_repo_name string | max_stars_repo_head_hexsha string | max_stars_repo_licenses list | max_stars_count int64 | max_stars_repo_stars_event_min_datetime string | max_stars_repo_stars_event_max_datetime string | max_issues_repo_path string | max_issues_repo_name string | max_issues_repo_head_hexsha string | max_issues_repo_licenses list | max_issues_count int64 | max_issues_repo_issues_event_min_datetime string | max_issues_repo_issues_event_max_datetime string | max_forks_repo_path string | max_forks_repo_name string | max_forks_repo_head_hexsha string | max_forks_repo_licenses list | max_forks_count int64 | max_forks_repo_forks_event_min_datetime string | max_forks_repo_forks_event_max_datetime string | content string | avg_line_length float64 | max_line_length int64 | alphanum_fraction float64 | qsc_code_num_words_quality_signal int64 | qsc_code_num_chars_quality_signal float64 | qsc_code_mean_word_length_quality_signal float64 | qsc_code_frac_words_unique_quality_signal float64 | qsc_code_frac_chars_top_2grams_quality_signal float64 | qsc_code_frac_chars_top_3grams_quality_signal float64 | qsc_code_frac_chars_top_4grams_quality_signal float64 | qsc_code_frac_chars_dupe_5grams_quality_signal float64 | qsc_code_frac_chars_dupe_6grams_quality_signal float64 | qsc_code_frac_chars_dupe_7grams_quality_signal float64 | qsc_code_frac_chars_dupe_8grams_quality_signal float64 | qsc_code_frac_chars_dupe_9grams_quality_signal float64 | qsc_code_frac_chars_dupe_10grams_quality_signal float64 | qsc_code_frac_chars_replacement_symbols_quality_signal float64 | qsc_code_frac_chars_digital_quality_signal float64 | qsc_code_frac_chars_whitespace_quality_signal float64 | qsc_code_size_file_byte_quality_signal float64 | qsc_code_num_lines_quality_signal float64 | qsc_code_num_chars_line_max_quality_signal float64 | qsc_code_num_chars_line_mean_quality_signal float64 | qsc_code_frac_chars_alphabet_quality_signal float64 | qsc_code_frac_chars_comments_quality_signal float64 | qsc_code_cate_xml_start_quality_signal float64 | qsc_code_frac_lines_dupe_lines_quality_signal float64 | qsc_code_cate_autogen_quality_signal float64 | qsc_code_frac_lines_long_string_quality_signal float64 | qsc_code_frac_chars_string_length_quality_signal float64 | qsc_code_frac_chars_long_word_length_quality_signal float64 | qsc_code_frac_lines_string_concat_quality_signal float64 | qsc_code_cate_encoded_data_quality_signal float64 | qsc_code_frac_chars_hex_words_quality_signal float64 | qsc_code_frac_lines_prompt_comments_quality_signal float64 | qsc_code_frac_lines_assert_quality_signal float64 | qsc_codepython_cate_ast_quality_signal float64 | qsc_codepython_frac_lines_func_ratio_quality_signal float64 | qsc_codepython_cate_var_zero_quality_signal bool | qsc_codepython_frac_lines_pass_quality_signal float64 | qsc_codepython_frac_lines_import_quality_signal float64 | qsc_codepython_frac_lines_simplefunc_quality_signal float64 | qsc_codepython_score_lines_no_logic_quality_signal float64 | qsc_codepython_frac_lines_print_quality_signal float64 | qsc_code_num_words int64 | qsc_code_num_chars int64 | qsc_code_mean_word_length int64 | qsc_code_frac_words_unique null | qsc_code_frac_chars_top_2grams int64 | qsc_code_frac_chars_top_3grams int64 | qsc_code_frac_chars_top_4grams int64 | qsc_code_frac_chars_dupe_5grams int64 | qsc_code_frac_chars_dupe_6grams int64 | qsc_code_frac_chars_dupe_7grams int64 | qsc_code_frac_chars_dupe_8grams int64 | qsc_code_frac_chars_dupe_9grams int64 | qsc_code_frac_chars_dupe_10grams int64 | qsc_code_frac_chars_replacement_symbols int64 | qsc_code_frac_chars_digital int64 | qsc_code_frac_chars_whitespace int64 | qsc_code_size_file_byte int64 | qsc_code_num_lines int64 | qsc_code_num_chars_line_max int64 | qsc_code_num_chars_line_mean int64 | qsc_code_frac_chars_alphabet int64 | qsc_code_frac_chars_comments int64 | qsc_code_cate_xml_start int64 | qsc_code_frac_lines_dupe_lines int64 | qsc_code_cate_autogen int64 | qsc_code_frac_lines_long_string int64 | qsc_code_frac_chars_string_length int64 | qsc_code_frac_chars_long_word_length int64 | qsc_code_frac_lines_string_concat null | qsc_code_cate_encoded_data int64 | qsc_code_frac_chars_hex_words int64 | qsc_code_frac_lines_prompt_comments int64 | qsc_code_frac_lines_assert int64 | qsc_codepython_cate_ast int64 | qsc_codepython_frac_lines_func_ratio int64 | qsc_codepython_cate_var_zero int64 | qsc_codepython_frac_lines_pass int64 | qsc_codepython_frac_lines_import int64 | qsc_codepython_frac_lines_simplefunc int64 | qsc_codepython_score_lines_no_logic int64 | qsc_codepython_frac_lines_print int64 | effective string | hits int64 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
3a10db88b8e63122312fa6eadb6be1464b7f840f | 134 | py | Python | backend/src/fibonacci/api/urls.py | alfonsorodrigo/fibonacci-series | 4e9290404037a0b6ef26043d4aab1e5de6c2ad82 | [
"MIT"
] | null | null | null | backend/src/fibonacci/api/urls.py | alfonsorodrigo/fibonacci-series | 4e9290404037a0b6ef26043d4aab1e5de6c2ad82 | [
"MIT"
] | 6 | 2021-03-18T23:53:51.000Z | 2021-09-22T18:36:27.000Z | backend/src/fibonacci/api/urls.py | alfonsorodrigo/fibonacci-series | 4e9290404037a0b6ef26043d4aab1e5de6c2ad82 | [
"MIT"
] | null | null | null | from django.urls import path
from .views import FibonacciSeries
urlpatterns = [
path('fibonacci/', FibonacciSeries.as_view())
]
| 16.75 | 49 | 0.746269 | 15 | 134 | 6.6 | 0.733333 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.149254 | 134 | 7 | 50 | 19.142857 | 0.868421 | 0 | 0 | 0 | 0 | 0 | 0.074627 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.4 | 0 | 0.4 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
3a16e456062aab19ac37b11ba7858d6e985cd3b4 | 368 | py | Python | verba/settings/testing.py | nhsuk/verba | c0354ae2012a046e7f7cc7482e293737de9d28bc | [
"MIT"
] | null | null | null | verba/settings/testing.py | nhsuk/verba | c0354ae2012a046e7f7cc7482e293737de9d28bc | [
"MIT"
] | 2 | 2016-08-11T09:30:41.000Z | 2016-08-11T15:04:08.000Z | verba/settings/testing.py | nhsuk/verba | c0354ae2012a046e7f7cc7482e293737de9d28bc | [
"MIT"
] | 1 | 2021-04-11T07:41:27.000Z | 2021-04-11T07:41:27.000Z | from .base import * # noqa
VERBA_CONFIG.update({
'GITHUB_HTTP_HOST': 'https://example.com',
'GITHUB_API_HOST': 'https://api.example.com',
'REPO': 'test-owner/test-repo'
})
VERBA_CONFIG['ASSIGNEES'] = {
'ALLOWED': ['test-owner', 'test-owner-2', 'test-developer'],
'WRITERS': ['test-owner', 'test-owner-2'],
'DEVELOPERS': ['test-developer']
}
| 26.285714 | 64 | 0.625 | 45 | 368 | 4.977778 | 0.511111 | 0.200893 | 0.174107 | 0.160714 | 0.169643 | 0 | 0 | 0 | 0 | 0 | 0 | 0.006369 | 0.146739 | 368 | 13 | 65 | 28.307692 | 0.707006 | 0.01087 | 0 | 0 | 0 | 0 | 0.558011 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.090909 | 0 | 0.090909 | 0 | 0 | 0 | 0 | null | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
3a21eae0f92710a574fbd3a4dae3608f04b49cdd | 364 | py | Python | main.py | hartono-wen/python-oop-skeleton | c132c3fabe2475bb24e76c97f10f14d1e8586112 | [
"MIT"
] | null | null | null | main.py | hartono-wen/python-oop-skeleton | c132c3fabe2475bb24e76c97f10f14d1e8586112 | [
"MIT"
] | null | null | null | main.py | hartono-wen/python-oop-skeleton | c132c3fabe2475bb24e76c97f10f14d1e8586112 | [
"MIT"
] | null | null | null | from entities.employee import *
from entities.department import *
from entities.company import *
hartono = employee("Hartono", '1980-01-01', "M", "+62-123-456-789", "hartono@test.com")
finance_department = department("finance", "Finance Department", 5)
hartono.save()
print(finance_department.id)
print(finance_department.name)
print(finance_department.floor)
| 26 | 87 | 0.766484 | 47 | 364 | 5.851064 | 0.489362 | 0.309091 | 0.24 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.060423 | 0.090659 | 364 | 13 | 88 | 28 | 0.770393 | 0 | 0 | 0 | 0 | 0 | 0.203297 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.333333 | 0 | 0.333333 | 0.333333 | 0 | 0 | 0 | null | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
3a2c008bc6e54b0303ecb579638f8655eb62b27b | 4,205 | py | Python | test_canSim.py | pm657/gdbp | b8b2b3145a830f52c1811b27a655600cd41e29a7 | [
"MIT"
] | null | null | null | test_canSim.py | pm657/gdbp | b8b2b3145a830f52c1811b27a655600cd41e29a7 | [
"MIT"
] | null | null | null | test_canSim.py | pm657/gdbp | b8b2b3145a830f52c1811b27a655600cd41e29a7 | [
"MIT"
] | null | null | null | import unittest
import canSim
import can
import tkinter
class CanSimTest(unittest.TestCase):
def test_types(self):
"""Test data types."""
self.assertIsInstance(canSim.interface, str)
self.assertIsInstance(canSim.channel, str)
self.assertIsInstance(canSim.freq, int)
self.assertIsInstance(canSim.bus, can.BusABC)
self.assertIsInstance(canSim.arbID, dict)
self.assertIsInstance(canSim.transmitState, tkinter.BooleanVar)
self.assertIsInstance(canSim.vehicleSpeed, tkinter.IntVar)
self.assertIsInstance(canSim.batterySoC, tkinter.IntVar)
self.assertIsInstance(canSim.batteryHealth, tkinter.IntVar)
self.assertIsInstance(canSim.fuelRange, tkinter.IntVar)
self.assertIsInstance(canSim.tripmeter, tkinter.IntVar)
self.assertIsInstance(canSim.batteryVol, tkinter.IntVar)
self.assertIsInstance(canSim.batteryTemp, tkinter.IntVar)
self.assertIsInstance(canSim.chargeState, tkinter.IntVar)
def test_values(self):
"""Test initial values of variables."""
self.assertEqual(canSim.interface, 'socketcan')
self.assertEqual(canSim.channel, 'vcan0')
self.assertEqual(canSim.freq, 20)
self.assertEqual(canSim.transmitState.get(), False)
self.assertEqual(canSim.chargeState.get(), 0)
self.assertEqual(canSim.arbID['vehSpeed'], 0x01)
self.assertEqual(canSim.arbID['batSoC'], 0x02)
self.assertEqual(canSim.arbID['batHea'], 0x03)
self.assertEqual(canSim.arbID['fuelR'], 0x04)
self.assertEqual(canSim.arbID['trip'], 0x05)
self.assertEqual(canSim.arbID['batVol'], 0x06)
self.assertEqual(canSim.arbID['batTemp'], 0x07)
self.assertEqual(canSim.arbID['charSta'], 0x08)
def test_sizes(self):
"""Test variable lengths."""
self.assertEqual(len(canSim.arbID), 8)
def test_encode(self):
"""Test encode function to ensure CAN frames are constructed correctly."""
self.assertIsInstance(canSim.encode(), list)
self.assertEqual(len(canSim.encode()), 8)
self.assertIsInstance(canSim.encode()[0], can.Message)
self.assertIsInstance(canSim.encode()[1], can.Message)
self.assertIsInstance(canSim.encode()[2], can.Message)
self.assertIsInstance(canSim.encode()[3], can.Message)
self.assertIsInstance(canSim.encode()[4], can.Message)
self.assertIsInstance(canSim.encode()[5], can.Message)
self.assertIsInstance(canSim.encode()[6], can.Message)
self.assertIsInstance(canSim.encode()[7], can.Message)
self.assertEqual(canSim.encode()[0].arbitration_id, 0x01)
self.assertEqual(canSim.encode()[1].arbitration_id, 0x02)
self.assertEqual(canSim.encode()[2].arbitration_id, 0x03)
self.assertEqual(canSim.encode()[3].arbitration_id, 0x04)
self.assertEqual(canSim.encode()[4].arbitration_id, 0x05)
self.assertEqual(canSim.encode()[5].arbitration_id, 0x06)
self.assertEqual(canSim.encode()[6].arbitration_id, 0x07)
self.assertEqual(canSim.encode()[7].arbitration_id, 0x08)
self.assertIsInstance(canSim.encode()[0].data, bytearray)
self.assertIsInstance(canSim.encode()[1].data, bytearray)
self.assertIsInstance(canSim.encode()[2].data, bytearray)
self.assertIsInstance(canSim.encode()[3].data, bytearray)
self.assertIsInstance(canSim.encode()[4].data, bytearray)
self.assertIsInstance(canSim.encode()[5].data, bytearray)
self.assertIsInstance(canSim.encode()[6].data, bytearray)
self.assertIsInstance(canSim.encode()[7].data, bytearray)
self.assertFalse(canSim.encode()[0].is_extended_id)
self.assertFalse(canSim.encode()[1].is_extended_id)
self.assertFalse(canSim.encode()[2].is_extended_id)
self.assertFalse(canSim.encode()[3].is_extended_id)
self.assertFalse(canSim.encode()[4].is_extended_id)
self.assertFalse(canSim.encode()[5].is_extended_id)
self.assertFalse(canSim.encode()[6].is_extended_id)
self.assertFalse(canSim.encode()[7].is_extended_id)
if __name__ == '__main__':
unittest.main()
| 45.706522 | 82 | 0.691795 | 466 | 4,205 | 6.165236 | 0.197425 | 0.142012 | 0.280543 | 0.189349 | 0.429864 | 0.306996 | 0.095023 | 0 | 0 | 0 | 0 | 0.024691 | 0.1717 | 4,205 | 91 | 83 | 46.208791 | 0.800172 | 0.033769 | 0 | 0 | 0 | 0 | 0.017566 | 0 | 0 | 0 | 0.015834 | 0 | 0.849315 | 1 | 0.054795 | false | 0 | 0.054795 | 0 | 0.123288 | 0 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
3a4646857a25dd835a6eb70c2d143848cba645fa | 76 | py | Python | sample_print.py | malai001/codebank | 6834107ab683a38a8799102278369a66b1c1b336 | [
"bzip2-1.0.6"
] | 1 | 2017-07-11T05:02:12.000Z | 2017-07-11T05:02:12.000Z | sample_print.py | malai001/codebank | 6834107ab683a38a8799102278369a66b1c1b336 | [
"bzip2-1.0.6"
] | null | null | null | sample_print.py | malai001/codebank | 6834107ab683a38a8799102278369a66b1c1b336 | [
"bzip2-1.0.6"
] | null | null | null |
a = ['123.pfx','456.pem']
for i in a:
if i.endswith('.pfx'):
print i | 15.2 | 26 | 0.526316 | 15 | 76 | 2.666667 | 0.733333 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.103448 | 0.236842 | 76 | 5 | 27 | 15.2 | 0.586207 | 0 | 0 | 0 | 0 | 0 | 0.25 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0 | null | null | 0.25 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
3a4f1add29cf9bcc7ff94a6c9cf2c1d73b728d2a | 30 | py | Python | bgscraper/__init__.py | AvidSoftware-be/ScrapeBGMenen | 48a558eaca063b612f0bc7c65d43576d3fbceb71 | [
"MIT"
] | 1 | 2016-04-05T20:46:17.000Z | 2016-04-05T20:46:17.000Z | bgscraper/__init__.py | AvidSoftware-be/ScrapeBGMenen | 48a558eaca063b612f0bc7c65d43576d3fbceb71 | [
"MIT"
] | null | null | null | bgscraper/__init__.py | AvidSoftware-be/ScrapeBGMenen | 48a558eaca063b612f0bc7c65d43576d3fbceb71 | [
"MIT"
] | null | null | null | __author__ = 'Dennis Decoene'
| 15 | 29 | 0.766667 | 3 | 30 | 6.333333 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.133333 | 30 | 1 | 30 | 30 | 0.730769 | 0 | 0 | 0 | 0 | 0 | 0.466667 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
28abf18ab30172beb16b79868c0f6946d8f593d2 | 143 | py | Python | thingsboard_gateway/connectors/mitsubishi/mitsubishi_plc_enum.py | xiaotangji/sinLot-gateway | 23680e96defa5af3fca772e4908b7387901c3e02 | [
"Apache-2.0"
] | 1 | 2021-11-24T02:44:58.000Z | 2021-11-24T02:44:58.000Z | thingsboard_gateway/connectors/mitsubishi/mitsubishi_plc_enum.py | xiaotangji/sinLot-gateway | 23680e96defa5af3fca772e4908b7387901c3e02 | [
"Apache-2.0"
] | null | null | null | thingsboard_gateway/connectors/mitsubishi/mitsubishi_plc_enum.py | xiaotangji/sinLot-gateway | 23680e96defa5af3fca772e4908b7387901c3e02 | [
"Apache-2.0"
] | null | null | null | from enum import Enum
class MitsubishiPlcConnectType(Enum):
BINARY = 0 # BINARY for 3E
ASCII = 1 # ASCII for 3E
A1E = 2 #
| 17.875 | 37 | 0.622378 | 19 | 143 | 4.684211 | 0.684211 | 0.11236 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.061224 | 0.314685 | 143 | 7 | 38 | 20.428571 | 0.846939 | 0.181818 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.2 | 0 | 1 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
28b2320d476457bfeb625b3893bd73165b238c16 | 9,272 | py | Python | code p2.py | harikan2007/virus | a20f3f47abc57c035f79ca71ac32078daa3dd534 | [
"Apache-2.0"
] | 1 | 2021-03-23T19:57:17.000Z | 2021-03-23T19:57:17.000Z | code p2.py | harikan2007/virus | a20f3f47abc57c035f79ca71ac32078daa3dd534 | [
"Apache-2.0"
] | null | null | null | code p2.py | harikan2007/virus | a20f3f47abc57c035f79ca71ac32078daa3dd534 | [
"Apache-2.0"
] | null | null | null | import numpy as np
L= int(input('L'))
N= int(input('N'))
T= int(input('T'))
p= int(input('Pacient number'))
pmariz=float(input('percentage of infection'))
ts=int(input('ts'))
counter=0
base=np.zeros((L,L),dtype=float)
randmake =np.random.randint(L, size=(2, N))
randmakep =np.random.randint(L, size=(2, p))
for i in range (0,N):#random maker
base[randmake[0][i]][randmake[1][i]]=1
for i in range (0,p):#random maker
base[randmakep[0][i]][randmakep[1][i]]=2
for i in range (0,T):
#################################################################################random walk
for x in range (1,L-2):#base base
for y in range (1,L-2):
if base[x][y] > 0.95:
direction = np.random.randint(low=0,high=3)
if direction ==0 and base[x-1][y]==0 :
base[x-1][y]=base[x][y]
base[x][y]=0
elif direction ==1 and base[x+1][y]==0 :
base[x+1][y]=base[x][y]
base[x][y]=0
elif direction ==2 and base[x][y-1]==0 :
base[x][y-1]=base[x][y]
base[x][y]=0
elif direction ==3 and base[x][y+1]==0 :
base[x][y+1]=base[x][y]
base[x][y]=0
for y in range (1,L-2):#base up
if base[0][y] >0.95:
direction = np.random.randint(low=0,high=2)
if direction ==0 and base[1][y]==0 :
base[1][y]=base[0][y]
base[0][y]=0
elif direction ==1 and base[x][y-1]==0:
base[x][y-1]=base[0][y]
base[0][y]=0
elif direction ==2 and base[x][y+1]==0 :
base[x][y+1]=base[0][y]
base[0][y]=0
for y in range (1,L-2):#base down
if base[L-1][y] >0.95:
direction = np.random.randint(low=0,high=2)
if direction ==0 and base[L-2][y]==0:
base[L-2][y]=base[L-1][y]
base[L-1][y]=0
elif direction ==1 and base[x][y-1]==0:
base[x][y-1]=base[L-1][y]
base[L-1][y]=0
elif direction ==2 and base[x][y+1]==0 :
base[x][y+1]=base[L-1][y]
base[L-1][y]=0
for x in range (1,L-2):#base left
if base[x][0] >0.95:
direction = np.random.randint(low=0,high=2)
if direction ==0 and base[x][1]==0 :
base[x][1]=base[x][0]
base[x][0]=0
elif direction ==1 and base[x-1][0]==0:
base[x-1][0]=base[x][0]
base[x][0]=0
elif direction ==2 and base[x+1][0]==0 :
base[x+1][0]=base[x][0]
base[x][0]=0
for x in range (1,L-2):#base right
if base[x][L-1] >0.95:
direction = np.random.randint(low=0,high=2)
if direction ==0 and base[x][L-1]==0:
base[x][L-2]=base[x][L-1]
base[x][L-1]=0
elif direction ==1 and base[x-1][L-1]==0 :
base[x-1][L-1]=base[x][L-1]
base[x][L-1]=0
elif direction ==2 and base[x+1][L-1]==0 :
base[x+1][L-1]=base[x][L-1]
base[x][L-1]=0
if base[0][0]>0.95:#corner LU
direction = np.random.randint(low=0,high=1)
if direction ==0 and base[0][1]==0:
base[0][1]=base[0][0]
base[0][0]=0
elif direction ==1 and base[1][0]==0 :
base[1][0]=base[0][0]
base[0][0]=0
if base[L-1][0]>0.95: #corner LD
direction = np.random.randint(low=0,high=1)
if direction ==0 and base[L-2][0]==0 :
base[L-2][0]=base[L-1][0]
base[L-1][0]=0
elif direction ==1 and base[L-1][1]==0 :
base[L-1][1]=base[L-1][0]
base[L-1][0]=0
if base[0][L-1]>0.95:#cornr RU
direction = np.random.randint(low=0,high=1)
if direction ==0 and base[0][L-2]==0 :
base[0][L-2]=base[0][L-1]
base[0][L-1]=0
elif direction ==1 and base[1][L-1]==0 :
base[1][L-1]=base[0][L-1]
base[0][L-1]=0
if base[L-1][L-1]>0.95: #corner RD
direction = np.random.randint(low=0,high=1)
if direction ==0 and base[L-2][L-1]==0 :
base[L-2][L-1]=base[L-1][L-1]
base[L-1][L-1]=0
elif direction ==1 and base[L-1][L-2]==0 :
base[L-1][L-2]=base[L-1][L-1]
base[L-1][L-1]=0
#############################################################################random walk
#############################################################################spread
for x in range (1,L-2):#base base
for y in range (1,L-2):
percentage = np.random.random()
if int(base[x][y]) ==2 and percentage<=p:
if int(base[x-1][y])==1.0:
base[x-1][y]=2
if int(base[x+1][y])==1.0:
base[x+1][y]=2
if int(base[x][y-1])==1.0:
base[x][y-1]=2
if int(base[x][y+1])==1.0:
base[x][y+1]=2
for y in range (1,L-2):#base up
percentage = np.random.random()
if int(base[0][y])==2 and percentage<=p:
if base[1][y]==1.0:
base[1][y]=2
if base[x][y-1]==1.0:
base[x][y-1]=2
if base[x][y+1]==1.0:
base[x][y+1]=2
for y in range (1,L-2):#base down
percentage = np.random.random()
if int(base[L-1][y]) ==2 and percentage<=p:
if base[L-2][y]==1.0:
base[L-2][y]=2
if base[x][y-1]==1.0:
base[x][y-1]=2
if base[x][y+1]==1.0:
base[x][y+1]=2
for x in range (1,L-2):#base left
percentage = np.random.random()
if int(base[x][0])==2 and percentage<=p:
if base[x][1]==1.0:
base[x][1]=2
if base[x-1][0]==1.0:
base[x-1][0]=2
if base[x+1][0]==1.0:
base[x+1][0]=2
for x in range (1,L-2):#base right
percentage = np.random.random()
if int(base[x][L-1])==2 and percentage<p:
if base[x][L-2]==1.0:
base[x][L-2]=2
if base[x-1][L-1]==1.0:
base[x-1][L-1]=2
if base[x+1][L-1]==1.0:
base[x+1][L-1]=2
if int(base[0][0])==2:#corner LU
percentage = np.random.random()
if base[0][1]==1.0 and percentage<=p:
base[0][1]=2
if base[1][0]==1.0 and percentage<=p:
base[1][0]=2
if int(base[L-1][0])==2: #corner LD
percentage = np.random.random()
if base[L-2][0]==1.0 and percentage<=p:
base[L-2][0]=2
if base[L-1][1]==1.0 and percentage<=p:
base[L-1][1]=2
if int(base[0][L-1])==2:#cornr RU
percentage = np.random.random()
if base[0][L-2]==1.0 and percentage<p:
base[0][L-2]=2
if base[1][L-1]==1.0 and percentage<=p:
base[1][L-1]=2
if int(base[L-1][L-1])==2: #corner RD
percentage = np.random.random()
if base[L-2][L-1]==1.0 and percentage<=p:
base[L-2][L-1]=2
if base[L-1][L-2]==1.0 and percentage<p:
base[L-1][L-2]=2
############################################################################spread
#############################################################################add time step
# for s in range (0,ts):
for x in range (0,L-1) :
for y in range (0,L-1):
if base[x][y]>3:
base[x][y]=1
if int(base[x][y])==2:
base[x][y]=base[x][y]+(1.0/ts)
##################################################################################time step
for x in range (0,L-1):
for y in range (0,L-1):
if int(base[x][y])>=2:
counter= counter+1
print(counter) | 37.088 | 98 | 0.35645 | 1,361 | 9,272 | 2.428362 | 0.045555 | 0.133132 | 0.072617 | 0.055068 | 0.842663 | 0.79062 | 0.744327 | 0.632073 | 0.518608 | 0.451437 | 0 | 0.088947 | 0.425259 | 9,272 | 250 | 99 | 37.088 | 0.531244 | 0.029659 | 0 | 0.364103 | 0 | 0 | 0.005086 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.005128 | 0 | 0.005128 | 0.005128 | 0 | 0 | 0 | null | 0 | 0 | 0 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
28b82260e0fedc3fd39e9c048a336da47a089c93 | 66 | py | Python | src/templates/python2/pattern_module/__init__.py | ErichDonGubler/CS-3450-Project-Templates | e77acd271466672d7aa04a26aeec0c28f55cdd35 | [
"Unlicense"
] | null | null | null | src/templates/python2/pattern_module/__init__.py | ErichDonGubler/CS-3450-Project-Templates | e77acd271466672d7aa04a26aeec0c28f55cdd35 | [
"Unlicense"
] | 4 | 2017-03-12T20:07:18.000Z | 2017-04-13T07:01:03.000Z | src/templates/python3/pattern_module/__init__.py | ErichDonGubler/CS-3450-Project-Templates | e77acd271466672d7aa04a26aeec0c28f55cdd35 | [
"Unlicense"
] | null | null | null | __all__ = ["pattern"]
from pattern_module.pattern import Pattern
| 16.5 | 42 | 0.787879 | 8 | 66 | 5.875 | 0.625 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.121212 | 66 | 3 | 43 | 22 | 0.810345 | 0 | 0 | 0 | 0 | 0 | 0.106061 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.5 | 0 | 0.5 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
28c44ce129b1026a3eef5d19229be75bb9140b0b | 137 | py | Python | db/location/createwxdbConfig.py | rand-projects/fisb-decode | 870f6be8b7e7013fcba0c4f2f894aae425700563 | [
"BSD-2-Clause-Patent"
] | 7 | 2021-05-29T13:12:20.000Z | 2021-12-26T02:38:34.000Z | db/location/createwxdbConfig.py | rand-projects/fisb-decode | 870f6be8b7e7013fcba0c4f2f894aae425700563 | [
"BSD-2-Clause-Patent"
] | null | null | null | db/location/createwxdbConfig.py | rand-projects/fisb-decode | 870f6be8b7e7013fcba0c4f2f894aae425700563 | [
"BSD-2-Clause-Patent"
] | null | null | null | """createwxdb configuration information.
"""
#: MongoDb URI where fisb_location DB is located.
MONGO_URI = 'mongodb://localhost:27017/'
| 22.833333 | 49 | 0.751825 | 16 | 137 | 6.3125 | 0.875 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.041322 | 0.116788 | 137 | 5 | 50 | 27.4 | 0.793388 | 0.627737 | 0 | 0 | 0 | 0 | 0.590909 | 0.590909 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
28cc5b607436dfa9c83e8ee3d5d1e23f10aad297 | 3,334 | py | Python | src/onegov/winterthur/collections/mission_report.py | politbuero-kampagnen/onegov-cloud | 20148bf321b71f617b64376fe7249b2b9b9c4aa9 | [
"MIT"
] | null | null | null | src/onegov/winterthur/collections/mission_report.py | politbuero-kampagnen/onegov-cloud | 20148bf321b71f617b64376fe7249b2b9b9c4aa9 | [
"MIT"
] | null | null | null | src/onegov/winterthur/collections/mission_report.py | politbuero-kampagnen/onegov-cloud | 20148bf321b71f617b64376fe7249b2b9b9c4aa9 | [
"MIT"
] | null | null | null | import sedate
from datetime import datetime, date
from onegov.core.collection import GenericCollection, Pagination
from onegov.org.models.file import ImageFileCollection
from onegov.winterthur.models import MissionReport
from onegov.winterthur.models import MissionReportFile
from onegov.winterthur.models import MissionReportVehicle
from sqlalchemy import and_, or_, desc, func
class MissionReportFileCollection(ImageFileCollection):
def __init__(self, session, report):
super().__init__(session)
self.type = 'mission-report-file'
self.report = report
@property
def id(self):
return self.report.id
@property
def association(self):
return MissionReportFile.registered_links['linked_mission_reports']
def add(self, *args, **kwargs):
file = super().add(*args, **kwargs)
self.report.pictures.append(file)
return file
def query(self):
query = super().query()
table = self.association.table
query = query.filter(MissionReportFile.id.in_(
self.session.query(table)
.with_entities(table.c.missionreportfile_id)
.filter(table.c.mission_reports_id == self.report.id)
.subquery()
))
return query
class MissionReportCollection(GenericCollection, Pagination):
def __init__(self, session, page=0, include_hidden=False, year=None):
self.session = session
self.page = page
self.include_hidden = include_hidden
self.year = year or date.today().year
@property
def model_class(self):
return MissionReport
def __eq__(self, other):
return self.page == other.page
def by_id(self, id):
# use the parent to get a report by id, so the date filter is
# not included, which is not desirable on this lookup
return super().query().filter(self.primary_key == id).first()
def query(self):
query = super().query()
if not self.include_hidden:
query = query.filter(or_(
MissionReport.meta['access'] == 'public',
MissionReport.meta['access'] == None
))
query = self.filter_by_year(query)
return query.order_by(desc(MissionReport.date))
def subset(self):
return self.query()
@property
def page_index(self):
return self.page
def page_by_index(self, index):
return self.__class__(self.session, page=index, year=self.year)
def filter_by_year(self, query):
timezone = 'Europe/Zurich'
start = sedate.replace_timezone(datetime(self.year, 1, 1), timezone)
end = sedate.replace_timezone(datetime(self.year + 1, 1, 1), timezone)
return query.filter(and_(
start <= MissionReport.date, MissionReport.date < end
))
def mission_count(self):
""" The mission count, including hidden missions. """
query = self.filter_by_year(super().query())
return query.with_entities(
func.sum(MissionReport.mission_count)).scalar()
class MissionReportVehicleCollection(GenericCollection):
@property
def model_class(self):
return MissionReportVehicle
def query(self):
return super().query().order_by(MissionReportVehicle.name)
| 28.991304 | 78 | 0.653269 | 378 | 3,334 | 5.613757 | 0.280423 | 0.032988 | 0.028275 | 0.036758 | 0.156456 | 0.091423 | 0.036758 | 0.036758 | 0 | 0 | 0 | 0.002389 | 0.246851 | 3,334 | 114 | 79 | 29.245614 | 0.842692 | 0.04769 | 0 | 0.189873 | 0 | 0 | 0.022734 | 0.006947 | 0 | 0 | 0 | 0 | 0 | 1 | 0.21519 | false | 0 | 0.101266 | 0.126582 | 0.544304 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
28d06690f8d085a48cd90199a95ebd2f7af33aec | 458 | py | Python | peeringdb_server/templatetags/two_factor_ext.py | CyberFlameGO/peeringdb | 83461deb58805fe1d83c5ff4276fa3bcb59a7323 | [
"BSD-2-Clause"
] | 224 | 2016-10-13T10:32:33.000Z | 2022-03-23T13:08:48.000Z | peeringdb_server/templatetags/two_factor_ext.py | CyberFlameGO/peeringdb | 83461deb58805fe1d83c5ff4276fa3bcb59a7323 | [
"BSD-2-Clause"
] | 1,063 | 2016-06-07T02:57:11.000Z | 2022-03-31T00:08:07.000Z | peeringdb_server/templatetags/two_factor_ext.py | CyberFlameGO/peeringdb | 83461deb58805fe1d83c5ff4276fa3bcb59a7323 | [
"BSD-2-Clause"
] | 92 | 2016-10-22T14:59:40.000Z | 2022-03-26T11:30:12.000Z | """
Template filters / tags to help with two-factor auth
"""
from django import template
from django.utils.translation import ugettext_lazy as _
from django_otp.plugins.otp_email.models import EmailDevice
from two_factor.templatetags import two_factor
register = template.Library()
@register.filter
def device_action(device):
if isinstance(device, EmailDevice):
return _("Email one time password")
return two_factor.device_action(device)
| 25.444444 | 59 | 0.783843 | 61 | 458 | 5.721311 | 0.57377 | 0.103152 | 0.103152 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.141921 | 458 | 17 | 60 | 26.941176 | 0.888041 | 0.113537 | 0 | 0 | 0 | 0 | 0.057789 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.1 | false | 0.1 | 0.4 | 0 | 0.7 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 1 | 0 | 0 | 3 |
28f5504b94d8fb97321943acef27fd63ecf3740d | 200 | py | Python | backend/payment/api/v1/serializers.py | crowdbotics-apps/shabeebapp-32726 | a739f4680342f9dff6ef9d967ba2bfecc0ebc27c | [
"FTL",
"AML",
"RSA-MD"
] | null | null | null | backend/payment/api/v1/serializers.py | crowdbotics-apps/shabeebapp-32726 | a739f4680342f9dff6ef9d967ba2bfecc0ebc27c | [
"FTL",
"AML",
"RSA-MD"
] | null | null | null | backend/payment/api/v1/serializers.py | crowdbotics-apps/shabeebapp-32726 | a739f4680342f9dff6ef9d967ba2bfecc0ebc27c | [
"FTL",
"AML",
"RSA-MD"
] | null | null | null | from rest_framework import serializers
from payment.models import Services
class ServicesSerializer(serializers.ModelSerializer):
class Meta:
model = Services
fields = "__all__"
| 22.222222 | 54 | 0.75 | 20 | 200 | 7.25 | 0.75 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.2 | 200 | 8 | 55 | 25 | 0.90625 | 0 | 0 | 0 | 0 | 0 | 0.035 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.333333 | 0 | 0.666667 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
28f8c6555acc34e1493b1a07f696e229b35a9ba2 | 2,664 | py | Python | src/zsl/errors.py | AtteqCom/zsl | 0d418ef957c9780263b1031dbc59482cd974bc04 | [
"MIT"
] | 2 | 2017-05-17T08:08:52.000Z | 2019-03-25T00:24:51.000Z | src/zsl/errors.py | AtteqCom/zsl | 0d418ef957c9780263b1031dbc59482cd974bc04 | [
"MIT"
] | 100 | 2017-01-11T13:43:11.000Z | 2022-02-10T09:27:18.000Z | src/zsl/errors.py | AtteqCom/zsl | 0d418ef957c9780263b1031dbc59482cd974bc04 | [
"MIT"
] | 1 | 2017-05-10T10:27:01.000Z | 2017-05-10T10:27:01.000Z | from abc import ABCMeta, abstractmethod
from typing import List
class ZslError(Exception):
"""
A base class intended for all exceptions thrown by ZSL or ZSL application.
"""
pass
ERROR_CONFIG_NAME = 'ERRORS'
class ErrorHandler(object):
"""
Custom error handler providing a response on a particular error.
"""
__metaclass__ = ABCMeta
@abstractmethod
def can_handle(self, e):
# type: (ErrorHandler, Exception)->bool
"""
Indicator if the handler is able to handle the given exception `e`.
:param e: The exception that shall be determined if can be handled by the handler.
:return: `True` or `False` depending on whether the handler can/should handle the method.
"""
pass
@abstractmethod
def handle(self, e):
# type: (ErrorHandler, Exception)->bool
"""
Handle the exception.
:param e: The handled exception.
:return: The error response for the exception.
"""
pass
class ErrorProcessor(object):
"""
Custom error processor handling an error state caused by an error. For example an error processor may only log an
error, send an email, etc. The main difference between an `ErrorProcessor` and an `ErrorHandler` is that the latter
one returns a response. There may be only a single `ErrorHandler` returning whereas there may be more
`ErrorProcessors` handling the same error.
"""
__metaclass__ = ABCMeta
@abstractmethod
def handle(self, e):
# type: (ErrorHandler, Exception)->None
pass
class ErrorConfiguration(object):
"""
The configuration object for error handling.
"""
def __init__(self, handlers=None, processors=None, use_flask_handler=False):
# type: (List[ErrorHandler], List[ErrorProcessor], bool)->None
self._use_flask_handler = use_flask_handler
self._handlers = handlers if handlers is not None else []
self._processors = processors if processors is not None else []
@property
def use_flask_handler(self):
# type:()->bool
"""
In case of web requests, flasks provides a convenient way of exception
handling. This handler shows the stack trace, etc. On the other hand \
this setting will turn of ZSL's exception handling for web request.
:return: Status
"""
return self._use_flask_handler
@property
def handlers(self):
# type: ()->List[ErrorHandler]
return self._handlers
@property
def processors(self):
# type: ()->List[ErrorProcessor]
return self._processors
| 29.274725 | 119 | 0.655781 | 320 | 2,664 | 5.3625 | 0.378125 | 0.02331 | 0.043706 | 0.026224 | 0.121795 | 0.087413 | 0.087413 | 0.061772 | 0 | 0 | 0 | 0 | 0.265015 | 2,664 | 90 | 120 | 29.6 | 0.876404 | 0.520646 | 0 | 0.4375 | 0 | 0 | 0.005561 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.21875 | false | 0.125 | 0.0625 | 0.0625 | 0.5625 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 3 |
e9011b871f550281faac20cea926075444a582c6 | 902 | py | Python | tests/mirror_init_tests/test_mirror_init_check_tree.py | ralphqq/gitchm | 1b403efb30fda127333575c131723a75200a0ab3 | [
"MIT"
] | 1 | 2020-07-06T17:43:52.000Z | 2020-07-06T17:43:52.000Z | tests/mirror_init_tests/test_mirror_init_check_tree.py | ralphqq/gitchm | 1b403efb30fda127333575c131723a75200a0ab3 | [
"MIT"
] | null | null | null | tests/mirror_init_tests/test_mirror_init_check_tree.py | ralphqq/gitchm | 1b403efb30fda127333575c131723a75200a0ab3 | [
"MIT"
] | null | null | null | import pytest
class TestCheckTreeState:
@pytest.fixture
def mirror(self, modified_chm):
return modified_chm["mirror"]
def test_check_dest_no_tree(self, mirror, dest_repo_no_tree):
mirror.dest_repo = dest_repo_no_tree
mirror._check_tree_state()
assert not mirror.dest_has_tree
def test_check_dest_tree(self, mirror, dest_repo_tree):
mirror.dest_repo = dest_repo_tree
mirror._check_tree_state()
assert mirror.dest_has_tree
def test_check_dest_mirror_master(self, mirror, dest_repo_mirror_master):
mirror.dest_repo = dest_repo_mirror_master
mirror._check_tree_state()
assert mirror.dest_has_tree
def test_check_dest_mirror_feature(self, mirror, dest_repo_mirror_feature):
mirror.dest_repo = dest_repo_mirror_feature
mirror._check_tree_state()
assert mirror.dest_has_tree
| 32.214286 | 79 | 0.733925 | 125 | 902 | 4.792 | 0.184 | 0.200334 | 0.186978 | 0.106845 | 0.784641 | 0.580968 | 0.343907 | 0.343907 | 0.288815 | 0.217028 | 0 | 0 | 0.2051 | 902 | 27 | 80 | 33.407407 | 0.835425 | 0 | 0 | 0.333333 | 0 | 0 | 0.006652 | 0 | 0 | 0 | 0 | 0 | 0.190476 | 1 | 0.238095 | false | 0 | 0.047619 | 0.047619 | 0.380952 | 0 | 0 | 0 | 0 | null | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
e90b5ad8662d73fc1e580af0512bffe44c5331a4 | 1,855 | py | Python | twitter_scraper/infrastructure/tests/test_utils.py | burakdonmez/twitter_scraper | 62d886ac7edb7a43d13ec6168ec930ff9b6efd08 | [
"MIT"
] | null | null | null | twitter_scraper/infrastructure/tests/test_utils.py | burakdonmez/twitter_scraper | 62d886ac7edb7a43d13ec6168ec930ff9b6efd08 | [
"MIT"
] | null | null | null | twitter_scraper/infrastructure/tests/test_utils.py | burakdonmez/twitter_scraper | 62d886ac7edb7a43d13ec6168ec930ff9b6efd08 | [
"MIT"
] | null | null | null | from django.test import TestCase
from twitter_scraper.infrastructure.utils import enforce_sequence, get_list
class EnforceSequenceTestCase(TestCase):
def test_given_not_sequence(self):
value = 1
expected_value = (value,)
result = enforce_sequence(value)
self.assertEqual(result, expected_value)
value = "dummy"
expected_value = (value,)
result = enforce_sequence(value)
self.assertEqual(result, expected_value)
value = {"a": "b"}
expected_value = (value,)
result = enforce_sequence(value)
self.assertEqual(result, expected_value)
def test_given_sequence(self):
value = [1, 2, 3]
result = enforce_sequence(value)
self.assertEqual(result, value)
value = (1, 2, 3)
result = enforce_sequence(value)
self.assertEqual(result, value)
class GetListTestCase(TestCase):
def test_given_dict_with_existing_keys(self):
value = {"a": {"b": {"c": 1}}}
expected_value = [1]
result = get_list(value, ["a", "b", "c"])
self.assertEqual(result, expected_value)
value = {"a": {"b": {"c": 2}}}
expected_value = [{"c": 2}]
result = get_list(value, ["a", "b"])
self.assertEqual(result, expected_value)
value = {"a": {"b": {"c": 2}}}
expected_value = [{"b": {"c": 2}}]
result = get_list(value, "a")
self.assertEqual(result, expected_value)
def test_given_dict_with_non_existing_keys(self):
value = {"a": {"b": {"c": 1}}}
expected_value = []
result = get_list(value, ["a", "d", "c"])
self.assertEqual(result, expected_value)
value = {"a": {"b": {"c": 2}}}
expected_value = []
result = get_list(value, "d")
self.assertEqual(result, expected_value)
| 30.409836 | 75 | 0.58814 | 212 | 1,855 | 4.933962 | 0.174528 | 0.198853 | 0.200765 | 0.221797 | 0.795411 | 0.735182 | 0.680688 | 0.640535 | 0.583174 | 0.583174 | 0 | 0.011005 | 0.265229 | 1,855 | 60 | 76 | 30.916667 | 0.75642 | 0 | 0 | 0.543478 | 0 | 0 | 0.018868 | 0 | 0 | 0 | 0 | 0 | 0.217391 | 1 | 0.086957 | false | 0 | 0.043478 | 0 | 0.173913 | 0 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
e92acdb5fa40f0dae082127092baecd1cf7eef71 | 2,255 | py | Python | results_plots/fall2021/resnet18_metaoverfitting.py | brando90/Does-MAML-Only-Work-via-Feature-Re-use-A-Data-Set-Centric-Perspective | 45c4fabf35d6d8d19e49092e84e8ac9fa55aee8d | [
"MIT"
] | null | null | null | results_plots/fall2021/resnet18_metaoverfitting.py | brando90/Does-MAML-Only-Work-via-Feature-Re-use-A-Data-Set-Centric-Perspective | 45c4fabf35d6d8d19e49092e84e8ac9fa55aee8d | [
"MIT"
] | null | null | null | results_plots/fall2021/resnet18_metaoverfitting.py | brando90/Does-MAML-Only-Work-via-Feature-Re-use-A-Data-Set-Centric-Perspective | 45c4fabf35d6d8d19e49092e84e8ac9fa55aee8d | [
"MIT"
] | null | null | null | #%%
# resnet18 meta-overfitting
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from pylab import MaxNLocator
import uutils
from pathlib import Path
print('running')
save_plot = True
# save_plot = False
# d: list[tuple[float, int, float]] = uutils.load_json_list(path='~/Desktop/', filename='run-.-tag-meta-train_loss.json')
# its, train_losses = uutils.torch_uu.tensorboard.tensorboard_run_list_2_matplotlib_list(d)
# d: list[tuple[float, int, float]] = uutils.load_json_list(path='~/Desktop/paper_figs', filename='run-.-tag-meta-val_loss.json')
# its, val_losses = uutils.torch_uu.tensorboard.tensorboard_run_list_2_matplotlib_list(d, 0.8)
# plt.plot(its, val_losses)
# plt.show()
# Plot the responses for different events and regions
# sns.lineplot(x="timepoint", y="signal",
# hue="region", style="event",
# data=fmri)
plt.show()
# - create plot
# fig, (loss_ax1, acc_ax2) = plt.subplots(nrows=2, ncols=1, sharex=True)
#
# # - plot stuff into loss axis
# loss_ax1.plot(experiment_stats['train']['its'], experiment_stats['train']['loss'],
# label=tag1, linestyle='-', marker='o', color='r', linewidth=1)
# loss_ax1.plot(experiment_stats['val']['its'], experiment_stats['val']['loss'],
# label=tag3, linestyle='-', marker='o', color='m', linewidth=1)
#
# loss_ax1.legend()
# loss_ax1.set_title(title)
# loss_ax1.set_ylabel('Loss')
# loss_ax1.grid(grid)
#
# # - plot stuff into acc axis
# acc_ax2.plot(experiment_stats['train']['its'], experiment_stats['train']['acc'],
# label=tag2, linestyle='-', marker='o', color='b', linewidth=1)
# acc_ax2.plot(experiment_stats['val']['its'], experiment_stats['val']['acc'],
# label=tag4, linestyle='-', marker='o', color='c', linewidth=1)
#
# acc_ax2.legend()
# x_axis_label: str = args.training_mode # epochs or iterations
# acc_ax2.set_xlabel(x_axis_label)
# acc_ax2.set_ylabel(ylabel_acc)
# acc_ax2.grid(grid)
#
# plt.tight_layout()
#
#
# if save_plot:
# root = Path('~/Desktop').expanduser()
# plt.savefig(root / 'pytorch_resnet18_metaoverfitting.png')
# plt.savefig(root / 'pytorch_resnet18_metaoverfitting.svg')
# plt.savefig(root / 'pytorch_resnet18_metaoverfitting.pdf')
#
# plt.show()
#
print('done') | 30.890411 | 129 | 0.697118 | 320 | 2,255 | 4.7125 | 0.378125 | 0.079576 | 0.050398 | 0.055703 | 0.377984 | 0.360743 | 0.27321 | 0.27321 | 0.153846 | 0.153846 | 0 | 0.018274 | 0.126386 | 2,255 | 73 | 130 | 30.890411 | 0.747208 | 0.859867 | 0 | 0 | 0 | 0 | 0.041667 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.6 | 0 | 0.6 | 0.2 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
3a5dc1fafa514ef7e46d384d5bd8fb166d6f583c | 310 | py | Python | validators.py | TerryLun/Rekognize | f557541c7f0f73e414d5caf313c3c6e710749b6b | [
"MIT"
] | null | null | null | validators.py | TerryLun/Rekognize | f557541c7f0f73e414d5caf313c3c6e710749b6b | [
"MIT"
] | null | null | null | validators.py | TerryLun/Rekognize | f557541c7f0f73e414d5caf313c3c6e710749b6b | [
"MIT"
] | null | null | null | def validate_extension(filename: str) -> bool:
"""
Validate file extension
:param filename: file name as string
:return: True if extension is allowed
"""
allowed_extensions = {'png', 'jpg', 'jpeg'}
return '.' in filename and filename.rsplit('.', 1)[1].lower() in allowed_extensions | 34.444444 | 87 | 0.658065 | 38 | 310 | 5.289474 | 0.657895 | 0.169154 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.00813 | 0.206452 | 310 | 9 | 87 | 34.444444 | 0.808943 | 0.319355 | 0 | 0 | 0 | 0 | 0.06383 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.333333 | false | 0 | 0 | 0 | 0.666667 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
3a61df471c8f4a42b72750b057f06b7bf3c6027d | 184 | py | Python | answer/a10_6_dict_sosa.py | breeze-shared-inc/python_training_01 | 7e918b37adbce062ae279f060bc25cfacda2fb85 | [
"MIT"
] | null | null | null | answer/a10_6_dict_sosa.py | breeze-shared-inc/python_training_01 | 7e918b37adbce062ae279f060bc25cfacda2fb85 | [
"MIT"
] | 1 | 2020-05-11T04:59:04.000Z | 2020-05-11T05:29:08.000Z | answer/a10_6_dict_sosa.py | bzgwhite/python_training_01 | 7e918b37adbce062ae279f060bc25cfacda2fb85 | [
"MIT"
] | null | null | null | my_dict = {
"key":"value",
"key2":"value2"
}
# dictに要素[key3:value3]を追加してみよう!
my_dict["key3"] = "value3"
print(my_dict)
# 識別子key2を削除してみよう!
my_dict.pop("key2")
print(my_dict)
| 13.142857 | 31 | 0.652174 | 25 | 184 | 4.6 | 0.52 | 0.26087 | 0.191304 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.050955 | 0.146739 | 184 | 13 | 32 | 14.153846 | 0.681529 | 0.25 | 0 | 0.25 | 0 | 0 | 0.237037 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.25 | 1 | 0 | 0 | null | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
3a791f814223a96b0799ee16ec1092384f8e2900 | 187 | py | Python | proj/ui.py | larsyencken/proj | 13c26c4a885d2f685ce92316b54e0526f347a57b | [
"BSD-3-Clause"
] | 1 | 2016-01-10T06:19:24.000Z | 2016-01-10T06:19:24.000Z | proj/ui.py | larsyencken/proj | 13c26c4a885d2f685ce92316b54e0526f347a57b | [
"BSD-3-Clause"
] | null | null | null | proj/ui.py | larsyencken/proj | 13c26c4a885d2f685ce92316b54e0526f347a57b | [
"BSD-3-Clause"
] | null | null | null | # -*- coding: utf-8 -*-
#
# ui.py
# proj
#
import sys
from typing import NoReturn
import click
def bail(message: str) -> NoReturn:
click.echo(message, err=True)
sys.exit(1)
| 11.6875 | 35 | 0.631016 | 27 | 187 | 4.37037 | 0.777778 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.013699 | 0.219251 | 187 | 15 | 36 | 12.466667 | 0.794521 | 0.181818 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.166667 | false | 0 | 0.5 | 0 | 0.666667 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
3a8ed8f96796575bc8698a57bea7cf3a181f332a | 51 | py | Python | sauri/messaging/blocking/protocols.py | healem/sauri | 3233106c830fdb2901d647a7019d61b290f9c727 | [
"MIT"
] | null | null | null | sauri/messaging/blocking/protocols.py | healem/sauri | 3233106c830fdb2901d647a7019d61b290f9c727 | [
"MIT"
] | null | null | null | sauri/messaging/blocking/protocols.py | healem/sauri | 3233106c830fdb2901d647a7019d61b290f9c727 | [
"MIT"
] | null | null | null | class Protocol:
AMQP = 'amqp'
MQTT = 'mqtt' | 17 | 17 | 0.568627 | 6 | 51 | 4.833333 | 0.666667 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.294118 | 51 | 3 | 18 | 17 | 0.805556 | 0 | 0 | 0 | 0 | 0 | 0.153846 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
3aecfd38f84b4ea88ac37f05f791a11cc10795a4 | 243 | py | Python | pynotify/apps.py | jsilhan/django-pynotify | 2c32f50d8fd35a8c2de2225125f1e19212ae0bde | [
"MIT"
] | 4 | 2019-03-21T01:03:55.000Z | 2019-10-01T13:11:04.000Z | pynotify/apps.py | jsilhan/django-pynotify | 2c32f50d8fd35a8c2de2225125f1e19212ae0bde | [
"MIT"
] | 29 | 2019-03-20T21:32:55.000Z | 2022-03-10T15:55:37.000Z | pynotify/apps.py | jsilhan/django-pynotify | 2c32f50d8fd35a8c2de2225125f1e19212ae0bde | [
"MIT"
] | 3 | 2019-03-27T20:13:00.000Z | 2021-11-10T18:28:00.000Z | from django.apps import AppConfig
from .helpers import autoload
class PyNotifyConfig(AppConfig):
name = 'pynotify'
verbose_name = 'PyNotify'
def ready(self):
from .notify import NotifyHandler # noqa
autoload()
| 18.692308 | 49 | 0.687243 | 26 | 243 | 6.384615 | 0.692308 | 0.144578 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.238683 | 243 | 12 | 50 | 20.25 | 0.897297 | 0.016461 | 0 | 0 | 0 | 0 | 0.067511 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.125 | false | 0 | 0.375 | 0 | 0.875 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
3af1a3f89fac0cd378a75b377158e7ac7ac98d93 | 257 | py | Python | loan_calculator/grossup/service_fee.py | yanomateus/loan-calculator | b6b8eb8102f40c4ec151ba2331e2122f6162f093 | [
"MIT"
] | 17 | 2020-02-15T20:14:49.000Z | 2022-03-16T01:00:00.000Z | loan_calculator/grossup/service_fee.py | yanomateus/loan-calculator | b6b8eb8102f40c4ec151ba2331e2122f6162f093 | [
"MIT"
] | null | null | null | loan_calculator/grossup/service_fee.py | yanomateus/loan-calculator | b6b8eb8102f40c4ec151ba2331e2122f6162f093 | [
"MIT"
] | 2 | 2021-01-03T19:14:29.000Z | 2021-06-01T06:24:25.000Z | def linear_service_fee(principal, fee=0.0):
"""Calculate service fee proportional to the principal.
If :math:`S` is the principal and :math:`g` is the fee aliquot, then the
fee is given by :math:`gS`.
"""
return float(principal * fee)
| 28.555556 | 76 | 0.669261 | 40 | 257 | 4.25 | 0.575 | 0.117647 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.009901 | 0.214008 | 257 | 8 | 77 | 32.125 | 0.831683 | 0.599222 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.5 | false | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
c90cbc97b74524f93d29e16032b9be65f6b77d90 | 208 | py | Python | Hackerrank/Regex/find-a-word.py | PROxZIMA/Competitive-Coding | ba6b365ea130b6fcaa15c5537b530ed363bab793 | [
"MIT"
] | 1 | 2021-01-10T13:29:21.000Z | 2021-01-10T13:29:21.000Z | Hackerrank/Regex/find-a-word.py | PROxZIMA/Competitive-Coding | ba6b365ea130b6fcaa15c5537b530ed363bab793 | [
"MIT"
] | null | null | null | Hackerrank/Regex/find-a-word.py | PROxZIMA/Competitive-Coding | ba6b365ea130b6fcaa15c5537b530ed363bab793 | [
"MIT"
] | null | null | null | import re
s = ''
for _ in range(int(input())):
s += input() + ' '
for _ in range(int(input())):
f = input()
regex = r'(?:(?<=[\W])|^)('+f+r')(?:(?=[\W])|$)'
print(len(re.findall(regex, s)))
| 18.909091 | 52 | 0.442308 | 29 | 208 | 3.103448 | 0.517241 | 0.111111 | 0.222222 | 0.288889 | 0.4 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.216346 | 208 | 10 | 53 | 20.8 | 0.552147 | 0 | 0 | 0.25 | 0 | 0 | 0.153846 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.125 | 0 | 0.125 | 0.125 | 1 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
c93e11bc2f1e6d984c586831707260a36aaf340f | 157 | py | Python | backend/apps/lymessages/apps.py | lybbn/django-vue3-lyadmin | df8ed48971eb3e3da977e1fd0467b1230b56afe4 | [
"MIT"
] | 1 | 2022-03-01T07:20:36.000Z | 2022-03-01T07:20:36.000Z | backend/apps/lymessages/apps.py | lybbn/django-vue3-lyadmin | df8ed48971eb3e3da977e1fd0467b1230b56afe4 | [
"MIT"
] | null | null | null | backend/apps/lymessages/apps.py | lybbn/django-vue3-lyadmin | df8ed48971eb3e3da977e1fd0467b1230b56afe4 | [
"MIT"
] | null | null | null | from django.apps import AppConfig
class LymessagesConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'apps.lymessages'
| 22.428571 | 56 | 0.770701 | 18 | 157 | 6.611111 | 0.833333 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.140127 | 157 | 6 | 57 | 26.166667 | 0.881481 | 0 | 0 | 0 | 0 | 0 | 0.280255 | 0.184713 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.25 | 0 | 1 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
a334ce64d5beb3d35c91fc36084bfbe81d57a6d3 | 1,450 | py | Python | MoinMoin/widget/dialog.py | RealTimeWeb/wikisite | 66a22c68c172f0ebb3c88a9885ccd33e2d59c3c5 | [
"Apache-2.0"
] | null | null | null | MoinMoin/widget/dialog.py | RealTimeWeb/wikisite | 66a22c68c172f0ebb3c88a9885ccd33e2d59c3c5 | [
"Apache-2.0"
] | 3 | 2020-06-26T21:21:32.000Z | 2020-06-26T21:21:36.000Z | wiki/MoinMoin/widget/dialog.py | simtk/src | 52086415ef60527e6556698c6e216e4217961d53 | [
"BSD-2-Clause",
"MIT"
] | 2 | 2017-01-25T20:06:44.000Z | 2021-03-25T18:39:55.000Z | # -*- coding: iso-8859-1 -*-
"""
MoinMoin - dialog
@copyright: 2004 Nir Soffer <nirs@freeshell.org>
@license: GNU GPL, see COPYING for details.
"""
from MoinMoin.widget import base
class Dialog(base.Widget):
""" Dialog for user interaction.
Use a dialog when you want to present and get data to the user.
Currently this is little more than wrapper around a string.
"""
def __init__(self, request, **kw):
""" Initialize a dialog
@param request: current request
@keyword content: dialong content
"""
base.Widget.__init__(self, request, **kw)
self.content = kw.get('content', '')
def render(self):
return u'<div class="dialog">\n%s\n</div>\n' % unicode(self.content)
class Status(base.Widget):
""" Status widget
Use Status when you want to present to the user status information,
and no interaction needed.
A user might choose to turn of status display in his user pref (not
implemented yet).
Currently this is little more than wrapper around a string.
"""
def __init__(self, request, **kw):
""" Initialize a dialog
@param request: current request
@keyword content: status message content
"""
base.Widget.__init__(self, request, **kw)
self.content = kw.get('content', '')
def render(self):
return u'<p class="status">%s</p>\n' % unicode(self.content)
| 25.438596 | 76 | 0.628966 | 190 | 1,450 | 4.715789 | 0.431579 | 0.044643 | 0.066964 | 0.075893 | 0.497768 | 0.453125 | 0.453125 | 0.453125 | 0.453125 | 0.453125 | 0 | 0.008341 | 0.255862 | 1,450 | 56 | 77 | 25.892857 | 0.822057 | 0.505517 | 0 | 0.615385 | 0 | 0 | 0.126712 | 0.089041 | 0 | 0 | 0 | 0 | 0 | 1 | 0.307692 | false | 0 | 0.076923 | 0.153846 | 0.692308 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
a33d13172811028b05c92b95f7168b5d9ef6bc9f | 109 | py | Python | SnackDown Round 1A/RRR.py | Jks08/CodeChef | a8aec8a563c441176a36b8581031764e99f09833 | [
"MIT"
] | 1 | 2021-09-17T13:10:04.000Z | 2021-09-17T13:10:04.000Z | SnackDown Round 1A/RRR.py | Jks08/CodeChef | a8aec8a563c441176a36b8581031764e99f09833 | [
"MIT"
] | null | null | null | SnackDown Round 1A/RRR.py | Jks08/CodeChef | a8aec8a563c441176a36b8581031764e99f09833 | [
"MIT"
] | null | null | null | t = int(input())
for i in range(t):
b,c=map(int,input().split())
ans = (2*b-c-1)//2
print(2*ans)
| 18.166667 | 32 | 0.513761 | 23 | 109 | 2.434783 | 0.652174 | 0.285714 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.047059 | 0.220183 | 109 | 5 | 33 | 21.8 | 0.611765 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.2 | 1 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
a362f1a87d2f866c16ee2f38faa543bff18b6fad | 267 | py | Python | src/test.py | Extomvi/CovidSDG | 29e773001d9ff69a598ebfc6c6860022fca250cf | [
"MIT"
] | 1 | 2020-04-08T01:34:11.000Z | 2020-04-08T01:34:11.000Z | src/test.py | Extomvi/CovidSDG | 29e773001d9ff69a598ebfc6c6860022fca250cf | [
"MIT"
] | null | null | null | src/test.py | Extomvi/CovidSDG | 29e773001d9ff69a598ebfc6c6860022fca250cf | [
"MIT"
] | 1 | 2020-04-13T17:15:17.000Z | 2020-04-13T17:15:17.000Z | import unittest
from unittest.mock import patch
import math
from unittest import mock
from unittest import TestCase
class EstimatorTest(unittest.TestCase):
def addition(self):
self.assertEqual((5+5), 10)
if __name__ == '__main__':
unittest.main() | 19.071429 | 39 | 0.737828 | 34 | 267 | 5.558824 | 0.529412 | 0.190476 | 0.190476 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.018182 | 0.17603 | 267 | 14 | 40 | 19.071429 | 0.840909 | 0 | 0 | 0 | 0 | 0 | 0.029851 | 0 | 0 | 0 | 0 | 0 | 0.1 | 1 | 0.1 | false | 0 | 0.5 | 0 | 0.7 | 0 | 0 | 0 | 0 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
a387e6d1e22d1a8734f0ead3052d1d7020c9879a | 614 | py | Python | src/part_1_coding/lessons/class_agregation.py | AndreiHustiuc/IT_Factory_Course | c6f3e4a9282a1c19c0f52c79f0c81f026814a02a | [
"MIT"
] | null | null | null | src/part_1_coding/lessons/class_agregation.py | AndreiHustiuc/IT_Factory_Course | c6f3e4a9282a1c19c0f52c79f0c81f026814a02a | [
"MIT"
] | null | null | null | src/part_1_coding/lessons/class_agregation.py | AndreiHustiuc/IT_Factory_Course | c6f3e4a9282a1c19c0f52c79f0c81f026814a02a | [
"MIT"
] | 1 | 2022-03-16T10:39:03.000Z | 2022-03-16T10:39:03.000Z | class Salary:
def __init__(self, pay):
self._pay = pay
def get_total(self):
return (self._pay * 12) // 4.9545
class SalarySenior:
def __init__(self, pay):
self._pay = pay
def get_total(self):
return (self._pay * 24) // 4.9545
class Employee:
def __init__(self, pay, bonus):
self._bonus = bonus
self._pay = pay
def annual_salary(self):
return f'Total salary is: {self._pay.get_total() + self._bonus}'
emp_middle = Employee(Salary(10000), 500)
emp_senior = Employee(SalarySenior(10000), 600)
print(emp_middle.annual_salary())
| 20.466667 | 72 | 0.630293 | 83 | 614 | 4.325301 | 0.313253 | 0.175487 | 0.091922 | 0.116992 | 0.289694 | 0.289694 | 0.289694 | 0.289694 | 0.289694 | 0.289694 | 0 | 0.064935 | 0.247557 | 614 | 29 | 73 | 21.172414 | 0.712121 | 0 | 0 | 0.368421 | 0 | 0 | 0.087948 | 0.035831 | 0 | 0 | 0 | 0 | 0 | 1 | 0.315789 | false | 0 | 0 | 0.157895 | 0.631579 | 0.052632 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
a39ff9dc220d497321630b2a44cf1ef1ae80ce84 | 5,025 | py | Python | ModelsFromText/text-to-triples-services/app_text_to_triples.py | GEGlobalResearch/DARPA-ASKE-TA1 | d2b06f4733be524bcfed1b5a288006e4c761118c | [
"BSD-3-Clause"
] | 6 | 2019-05-09T18:58:31.000Z | 2021-05-06T15:02:38.000Z | ModelsFromText/text-to-triples-services/app_text_to_triples.py | GEGlobalResearch/DARPA-ASKE-TA1 | d2b06f4733be524bcfed1b5a288006e4c761118c | [
"BSD-3-Clause"
] | 64 | 2019-09-09T13:48:09.000Z | 2022-03-02T14:23:17.000Z | ModelsFromText/text-to-triples-services/app_text_to_triples.py | GEGlobalResearch/DARPA-ASKE-TA1 | d2b06f4733be524bcfed1b5a288006e4c761118c | [
"BSD-3-Clause"
] | 4 | 2019-07-15T13:11:28.000Z | 2021-05-06T15:03:07.000Z | '''
/**********************************************************************
* Note: This license has also been called the "New BSD License" or
* "Modified BSD License". See also the 2-clause BSD License.
*
* Copyright © 2018-2019 - General Electric Company, All Rights Reserved
*
* Project: ANSWER, developed with the support of the Defense Advanced
* Research Projects Agency (DARPA) under Agreement No. HR00111990006.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*
***********************************************************************/
'''
# This Python file uses the following encoding: utf-8
import config
import connexion
import text_to_triples_service as t2t
import text_to_triples_backward_compatible_service as t2tbcs
import locality_search as locality
import units_extraction as units
import text_to_ontology as t2o
import sys
from flask_cors import CORS
# Service Initialization. Load config file to set appropriate properties
app_text_to_triples = connexion.App(__name__, specification_dir='swagger/')
application = app_text_to_triples.app
# TODO: Error Handling if config file is not provided.
# TODO: If argv[1] is absent, use default config file from resources
application.config['config_file'] = sys.argv[1]
config = config.Config(sys.argv[1])
application.config['config_obj'] = config
# Initialize text to triples object
t2t_obj = t2t.TextToTriples(application.config['config_obj'])
# Initialize the units extraction object
units_extract = units.UnitsExtraction(application.config['config_obj'])
def text_to_triples(body):
return t2t_obj.text_to_triples(body)
def get_equation_var_context(body):
# return locality.get_equation_var_context(body, application.config['config_obj'])
return locality.local_variable_search(body, t2t_obj, config)
def get_units_info(body):
return units_extract.extract_units(body["text"], body["localityURI"], t2t_obj)
def save_graph(body):
g = t2t_obj.get_graph(body["localityURI"])
return t2t_obj.save_graph(g)
def clear_graph(body):
return t2t_obj.clear_graph(body["localityURI"])
def upload_domain_ontology(body):
return t2t_obj.upload_domain_ontology(body["localityURI"], body["baseURI"], body["ontologyAsString"])
def text_to_ontology(body):
return t2o.get_ontology_from_text(body, application.config['config_obj'])
# TODO: Backward compatible method. Need to retire. Do not use.
def text_to_triples_backward_compatible(body):
return t2tbcs.text_to_triples_backward_compatible(body, application.config['config_obj'])
def get_equations(body):
g = t2t_obj.get_graph(body["localityURI"])
return t2t.get_equations(g)
def run_queries(body):
g = t2t_obj.get_graph(body["localityURI"])
return t2t.run_queries(g)
def process_example_doc(body):
file_path = "demo/" + str(body["docId"]) + ".txt"
file = open(file_path, 'r')
content = file.readlines()
text = ""
for con in content:
text = text + " " + con
return t2tbcs.text_to_triples_backward_compatible({"text": text, "localityURI": "string"},
application.config['config_obj'])
if __name__ == '__main__':
app_text_to_triples.add_api('text2triplesapi.yaml')
CORS(app_text_to_triples.app)
# print(application.config.get('config_file'))
# app_text_to_triples.app.config['config_file'] = sys.argv[1]
# print(app_text_to_triples.config.get('config_file'))
app_text_to_triples.run(host='0.0.0.0', port=4200)
app_text_to_triples.run(port=4200)
| 35.892857 | 105 | 0.729353 | 690 | 5,025 | 5.131884 | 0.362319 | 0.0305 | 0.05874 | 0.036148 | 0.229879 | 0.143462 | 0.118893 | 0.094606 | 0.074838 | 0.074838 | 0 | 0.014201 | 0.159204 | 5,025 | 139 | 106 | 36.151079 | 0.823669 | 0.525572 | 0 | 0.056604 | 0 | 0 | 0.103128 | 0 | 0 | 0 | 0 | 0.007194 | 0 | 1 | 0.207547 | false | 0 | 0.169811 | 0.132075 | 0.584906 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
6e7ba1174b5e55b041392d08b91c01037d8502e0 | 10,692 | py | Python | Utils/py/ActionSelection/experimental/QLearning/gamefield.py | tarsoly/NaoTH | dcd2b67ef6bf9953c81d3e1b26e543b5922b7d52 | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | Utils/py/ActionSelection/experimental/QLearning/gamefield.py | tarsoly/NaoTH | dcd2b67ef6bf9953c81d3e1b26e543b5922b7d52 | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | Utils/py/ActionSelection/experimental/QLearning/gamefield.py | tarsoly/NaoTH | dcd2b67ef6bf9953c81d3e1b26e543b5922b7d52 | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | from tools import field_info as field
from Tkinter import *
import threading
import time
master = Tk()
# create functions to draw field + decisions made / q values ranging from green to red
# draw field + update field
square_size = 200 # relative to field
field_x = field.x_field_length + 200 # add a few pixels, for better devision
field_y = field.y_field_length + 200 # no consequences for the calculation since outside the gamefield
columns = field_x / square_size
rows = field_y / square_size
square_display_size = 10
board_x = columns * square_display_size
board_y = rows * square_display_size
actions = ["right" ,"up" ,"down", "left"]
field = {} # general field i.e. cells and arrows
specials = {} # goals, outlying area
def fill_specials():
for i in range(columns):
for j in range(rows):
# add own goal
if (3000 <= j * square_size < 4600) and (0 <= i * square_size < 800):
specials[(i, j)] = (-1., "red")
elif (3000 <= j * square_size < 4600) and (9800 <= i * square_size < 10600):
specials[(i, j)] = (1., "green")
elif j * square_size < 800 or j * square_size >= 6800 or i * square_size < 800 or i * square_size >= 9800:
specials[(i, j)] = (-0.7, "orange")
fill_specials()
agent_start_position = (30,30)
agent_position = agent_start_position
reset = False
score_min, score_max = -0.2, 0.2
score = 1
move_cost = -0.01
def move_cost_action():
# move cost in relation to actio
pass
board = Canvas(master, width= board_x, height=board_y)
def create_world():
# create world elements
global square_display_size, rows, columns, field
for j in range(rows):
for i in range(columns):
field[(i,j)] = []
# create fields
# add special fields
if (i,j) in specials:
field[(i, j)].append(board.create_rectangle(i * square_display_size, j * square_display_size,
(i + 1) * square_display_size, (j + 1) * square_display_size, fill=specials[(i,j)][1], width=1))
# fill everything else white - denoted as neutral
else:
field[(i, j)].append(board.create_rectangle(i * square_display_size, j * square_display_size,
(i + 1) * square_display_size, (j + 1) * square_display_size, fill="white", width=1))
# add arrows in fields
field[(i,j)].append(board.create_line(i * square_display_size + 2, j * square_display_size + 0.5 * square_display_size,
(i + 1) * square_display_size - 2 , j * square_display_size + 0.5 * square_display_size,
fill="black"))
def update_arrow(coords, action):
(i, j) = coords
# update arrow(heads)
if action == "up":
board.coords(field[coords][1], i*square_display_size + 0.5*square_display_size, (j+1)*square_display_size,
i*square_display_size + 0.5*square_display_size, j*square_display_size)
board.itemconfigure(field[coords][1],arrow="last")
elif action == "down":
board.coords(field[coords][1], i*square_display_size + 0.5*square_display_size, j*square_display_size,
i*square_display_size + 0.5*square_display_size, (j+1)*square_display_size)
board.itemconfigure(field[coords][1],arrow="last")
elif action == "right":
board.coords(field[coords][1], i*square_display_size, j*square_display_size + 0.5*square_display_size,
(i+1)*square_display_size, j*square_display_size + 0.5*square_display_size)
board.itemconfigure(field[coords][1],arrow="last")
elif action == "left":
board.coords(field[coords][1], (i+1)*square_display_size, j*square_display_size + 0.5*square_display_size,
i*square_display_size, j*square_display_size + 0.5*square_display_size)
board.itemconfigure(field[coords][1],arrow="last")
else:
print "no arrow drawn for field: ", (i,j)
def set_cell_color(coords, val):
global score_min, score_max
cell = field[coords][0]
# color setting
green_dec = int(min(255, max(0, (val - score_min) * 255.0 / (score_max - score_min))))
green = hex(green_dec)[2:]
red = hex(255-green_dec)[2:]
if len(red) == 1:
red += "0"
if len(green) == 1:
green += "0"
color = "#" + red + green + "00"
board.itemconfigure(cell, fill=color)
def convert((x,y)):
# TODO: So nicht richtig, da Anstosspunkt = Mittelpunkt
# converts field position to cell in the grid
i = int( x / square_size )
j = int( y / square_size )
return (i,j)
def move_agent(absolute = None, relative = None):
global agent_position
# set new coords for the agent
if absolute != None:
agent_position = absolute
if relative != None:
agent_position = (agent_position[0] + relative[0], agent_position[1] + relative[1])
# display agent at new place
board.coords(agent_display, agent_position[0] * square_display_size, agent_position[1] * square_display_size,
(agent_position[0] + 1) * square_display_size, (agent_position[1] + 1) * square_display_size)
def reset_agent():
global agent_position, score, agent_display, reset, agent_start_position
agent_position = agent_start_position
score = 1 # don't know yet what this is for, remains since it could be forgotten otherwise
reset = False
board.coords(agent_display, agent_position[0] * square_display_size, agent_position[1] * square_display_size,
(agent_position[0] + 1) * square_display_size, (agent_position[1] + 1) * square_display_size)
def check_infield(coords):
(i,j) = coords
if (800 <= j * square_size < 6800) and (800 <= i * square_size < 9800):
return True
else:
return False
# TODO: def check_special for special events like goal or out
def check_special(coords):
if coords in specials:
return True
else:
return False
"""
def render_grid():
global square_display_size, rows, columns
for i in range(rows):
for j in range(columns):
# own and opp goal as green and red fields
if (3000 <= j*square_size < 4600) and (0 <= i*square_size < 800):
board.create_rectangle(i * square_display_size, j * square_display_size, (i + 1) * square_display_size,
(j + 1) * square_display_size, fill="red", width=1)
elif (3000 <= j*square_size < 4600) and (9800 <= i*square_size < 10600):
board.create_rectangle(i * square_display_size, j * square_display_size, (i + 1) * square_display_size,
(j + 1) * square_display_size, fill="green", width=1)
# outer field in orange
elif j*square_size < 800 or j*square_size >= 6800 or i*square_size < 800 or i*square_size >= 9800:
board.create_rectangle(i * square_display_size, j * square_display_size, (i + 1) * square_display_size,
(j + 1) * square_display_size, fill="orange", width=1)
# innerfield white
else:
board.create_rectangle(i*square_display_size, j*square_display_size, (i+1)*square_display_size,
(j+1)*square_display_size, fill="white", width=1)
"""
"""
def draw_arrow(coords,action):
(i, j) = coords
if action == "up":
board.create_line(i*square_display_size + 0.5*square_display_size, (j+1)*square_display_size, i*square_display_size + 0.5*square_display_size, j*square_display_size, fill="black", arrow="last")
elif action == "down":
board.create_line(i*square_display_size + 0.5*square_display_size, j*square_display_size, i*square_display_size + 0.5*square_display_size, (j+1)*square_display_size, fill="black", arrow="last")
elif action == "right":
board.create_line(i*square_display_size, j*square_display_size + 0.5*square_display_size, (i+1)*square_display_size, j*square_display_size + 0.5*square_display_size, fill="black", arrow="last")
elif action == "left":
board.create_line((i+1)*square_display_size, j*square_display_size + 0.5*square_display_size, i*square_display_size, j*square_display_size + 0.5*square_display_size, fill="black", arrow="last")
else:
print "no arrow drawn for field: ", (i,j)
"""
"""
def create_arrows():
global arrows
for i in range(rows):
for j in range(columns):
if (800 <= j * square_size < 6800) and (800 <= i * square_size < 9800):
arrows[(i,j)] = board.create_line(i * square_display_size + 2, j * square_display_size + 0.5 * square_display_size,
(i + 1) * square_display_size - 2 , j * square_display_size + 0.5 * square_display_size,
fill="black")
"""
# TODO: add try_move function
def try_move(relative_coords):
global agent_position, reset, score, specials
if reset == True:
reset_agent() # used in special occasions e.g. force stop or enemies / opponents
(dx ,dy) = relative_coords
if agent_position[0] + dx < agent_start_position[0]-1: # don't allow to go behind starting position
reset = True
score -= 1.
print "don't go back!"
return
if check_special((agent_position[0] + dx, agent_position[1] + dy)):
special_field = specials[(agent_position[0] + dx, agent_position[1] + dy)]
score += move_cost
score += special_field[0]
if score > 1:
print "GOAL!"
else:
print "next time..."
print "Final score: ", score
reset = True
return
elif check_infield((agent_position[0] + dx, agent_position[1] + dy)):
score += move_cost
move_agent(relative=(dx, dy))
else:
print "unkown situation \n resetting agent..."
reset = True
return
if score < -40.:
reset = True
#print "score: ", score
create_world()
board.grid(row=0, column=0)
agent_display = board.create_oval(agent_position[0]*square_display_size,agent_position[1]*square_display_size,
(agent_position[0]+1)*square_display_size,(agent_position[1]+1)*square_display_size,fill="orange", width=1, tag="agent")
def test_run():
global agent_position
# run routine
while True:
try_move((1,1))
time.sleep(0.05)
def start_field():
master.mainloop()
"""
t = threading.Thread(target=test_run)
t.daemon = True
t.start()
master.mainloop()
"""
| 36.868966 | 202 | 0.62832 | 1,491 | 10,692 | 4.277666 | 0.142857 | 0.205864 | 0.269207 | 0.087488 | 0.577924 | 0.546723 | 0.517717 | 0.515365 | 0.505958 | 0.492004 | 0 | 0.03601 | 0.254583 | 10,692 | 289 | 203 | 36.99654 | 0.764241 | 0.089039 | 0 | 0.282895 | 0 | 0 | 0.02883 | 0 | 0 | 0 | 0 | 0.00692 | 0 | 0 | null | null | 0.006579 | 0.026316 | null | null | 0.039474 | 0 | 0 | 0 | null | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
6eb28e7c085a835938ad8ac2e118e8a19af277d4 | 19 | py | Python | diamond_agent/tests/resources/__init__.py | junaid-ali/cloudify-diamond-plugin | 1bdca486271231c5e437dc0ac1c70b6c100829e4 | [
"Apache-2.0"
] | 58 | 2015-01-11T09:05:15.000Z | 2022-03-17T23:44:07.000Z | ckanext-ytp-request/__init__.py | datopian/hdx-ckan | 2d8871c035a18e48b53859fec522b997b500afe9 | [
"Apache-2.0"
] | 1,467 | 2015-01-01T16:47:44.000Z | 2022-02-28T16:51:20.000Z | ckanext-ytp-request/__init__.py | datopian/hdx-ckan | 2d8871c035a18e48b53859fec522b997b500afe9 | [
"Apache-2.0"
] | 17 | 2015-05-06T14:04:21.000Z | 2021-11-11T19:58:16.000Z | __author__ = 'dan'
| 9.5 | 18 | 0.684211 | 2 | 19 | 4.5 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.157895 | 19 | 1 | 19 | 19 | 0.5625 | 0 | 0 | 0 | 0 | 0 | 0.157895 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
6ef0495d6d445aec4e0ec67baa24a3cd3ef804f2 | 596 | py | Python | offer/urls.py | noriHanda/study_matching | 55e9525c9502c45c799f8f3a4c9c2b54406ed9e1 | [
"MIT"
] | null | null | null | offer/urls.py | noriHanda/study_matching | 55e9525c9502c45c799f8f3a4c9c2b54406ed9e1 | [
"MIT"
] | null | null | null | offer/urls.py | noriHanda/study_matching | 55e9525c9502c45c799f8f3a4c9c2b54406ed9e1 | [
"MIT"
] | null | null | null | from rest_framework import routers
from .views import OfferViewSet
from . import views
from django.urls import path
router = routers.DefaultRouter()
router.register(r'', OfferViewSet)
app_name = 'offer'
urlpatterns = [
path('fetch_user_offer_set_list', views.fetch_user_offer_set_list, name='fetch_user_offer_set_list'),
path('fetch_user_offer_set_list_logged_out', views.fetch_user_offer_set_list_logged_out, name='fetch_user_offer_set_list_logged_out'),
path('fetch_individual_user_offer_list', views.fetch_individual_user_offer_list, name='fetch_individual_user_offer_list'),
]
| 37.25 | 138 | 0.825503 | 88 | 596 | 5.090909 | 0.284091 | 0.180804 | 0.1875 | 0.227679 | 0.587054 | 0.399554 | 0.200893 | 0 | 0 | 0 | 0 | 0 | 0.087248 | 596 | 15 | 139 | 39.733333 | 0.823529 | 0 | 0 | 0 | 0 | 0 | 0.32047 | 0.312081 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.333333 | 0 | 0.333333 | 0 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
42cd34b2ad613aa98d79191014bb7e327cb6c86d | 963 | py | Python | SAMKNN/BaseClassifier.py | johaq/SAMkNN | bbb8124f334946a794b48daa45ddada2b337dbb8 | [
"MIT"
] | 3 | 2018-11-20T13:52:17.000Z | 2019-10-08T13:49:40.000Z | SAMKNN/BaseClassifier.py | johaq/SAMkNN | bbb8124f334946a794b48daa45ddada2b337dbb8 | [
"MIT"
] | null | null | null | SAMKNN/BaseClassifier.py | johaq/SAMkNN | bbb8124f334946a794b48daa45ddada2b337dbb8 | [
"MIT"
] | 7 | 2017-03-16T19:07:32.000Z | 2021-03-25T01:19:43.000Z | __author__ = 'vlosing'
class BaseClassifier(object):
"""
Base class for classifier.
"""
def __init__(self):
pass
def fit(self, samples, labels, epochs):
raise NotImplementedError()
def partial_fit(self, samples, labels, classes):
raise NotImplementedError()
def alternateFitPredict(self, samples, labels, classes):
raise NotImplementedError()
def predict(self, samples):
raise NotImplementedError()
def predict_proba(self, samples):
raise NotImplementedError()
def getInfos(self):
raise NotImplementedError()
def getComplexity(self):
raise NotImplementedError()
def getComplexityNumParameterMetric(self):
raise NotImplementedError()
def trainOnline(self, X, y, classes):
predictedLabels = self.alternateFitPredict(X, y, classes)
return predictedLabels, self.getComplexity(), self.getComplexityNumParameterMetric()
| 26.75 | 92 | 0.681205 | 84 | 963 | 7.690476 | 0.369048 | 0.297214 | 0.334365 | 0.143963 | 0.275542 | 0.157895 | 0.157895 | 0 | 0 | 0 | 0 | 0 | 0.228453 | 963 | 35 | 93 | 27.514286 | 0.869448 | 0.026999 | 0 | 0.347826 | 0 | 0 | 0.0076 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.434783 | false | 0.043478 | 0 | 0 | 0.521739 | 0 | 0 | 0 | 0 | null | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
6e13a32763d0fefe4461be7b367f24b7d381e9d8 | 84 | py | Python | exts.py | Fireblossom/project_save_roommate | 3fe9ec368ec4a9205d6c368ec8be43e9adc3b26b | [
"MIT"
] | null | null | null | exts.py | Fireblossom/project_save_roommate | 3fe9ec368ec4a9205d6c368ec8be43e9adc3b26b | [
"MIT"
] | null | null | null | exts.py | Fireblossom/project_save_roommate | 3fe9ec368ec4a9205d6c368ec8be43e9adc3b26b | [
"MIT"
] | null | null | null | #encoding: utf-8
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
| 12 | 40 | 0.714286 | 10 | 84 | 5.9 | 0.8 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.015152 | 0.214286 | 84 | 6 | 41 | 14 | 0.878788 | 0.178571 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.5 | 0 | 0.5 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
6e165f46d6bd3b285932264fb0aeef82c51c084b | 594 | py | Python | scte35/exceptions.py | spsandiford/scte35-python | c325b170b87164da9cd08802d4861149596cd231 | [
"MIT"
] | 2 | 2020-01-16T09:55:52.000Z | 2020-05-14T09:10:47.000Z | scte35/exceptions.py | spsandiford/scte35-python | c325b170b87164da9cd08802d4861149596cd231 | [
"MIT"
] | null | null | null | scte35/exceptions.py | spsandiford/scte35-python | c325b170b87164da9cd08802d4861149596cd231 | [
"MIT"
] | null | null | null | class InvalidTableIdException(Exception):
"""
Indicate that the table id was not 0xFC as required
"""
pass
class ReservedBitsException(Exception):
"""
Indicate that bits reserved by the specification were not set to 1 as required
"""
pass
class SectionParsingErrorException(Exception):
pass
class NotAnHLSCueTag(Exception):
pass
class NotImplementedException(Exception):
pass
class NoSegmentationDescriptorException(Exception):
pass
class FieldNotDefinedException(Exception):
pass
class MissingCueException(Exception):
pass
| 16.054054 | 82 | 0.734007 | 56 | 594 | 7.785714 | 0.517857 | 0.144495 | 0.206422 | 0.087156 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.004237 | 0.205387 | 594 | 36 | 83 | 16.5 | 0.919492 | 0.218855 | 0 | 0.5 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0.5 | 0 | 0 | 0.5 | 0 | 0 | 0 | 0 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 3 |
6e26b9e2ea9ae8150c9b06e6fef6f308abfd2722 | 1,093 | py | Python | geology.py | johwiebe/drill-scheduling | c070adde1b9e8eacbe333a570cf1fc5e480f2f32 | [
"MIT"
] | 1 | 2021-09-16T19:36:33.000Z | 2021-09-16T19:36:33.000Z | geology.py | johwiebe/drill-scheduling | c070adde1b9e8eacbe333a570cf1fc5e480f2f32 | [
"MIT"
] | null | null | null | geology.py | johwiebe/drill-scheduling | c070adde1b9e8eacbe333a570cf1fc5e480f2f32 | [
"MIT"
] | null | null | null | #!/usr/bin/env
"""geology.py: tools for modeling geology."""
import bisect
class Rock():
""" Stores rock parameters for Detournay bit-rock interaction model. """
def __init__(self, Sstar, wstar, xieps, mugam, betaw, xi):
self.Sstar = Sstar
self.wstar = wstar
self.xieps = xieps
self.mugam = mugam
self.betaw = betaw
self.xi = xi
class Geology():
""" Stores geology as a list of rock types. """
def __init__(self, data):
self.data = data
self.transitions = list(data.keys())
self.transitions.sort()
def lookup(self, x):
""" Look up rock parameters at depth/length x. """
key = max(key for key in self.data.keys() if x - key >= 0)
return self.data[key]
def __call__(self, x):
return self.lookup(x)
def segment(self, x):
return bisect.bisect_left(self.transitions, x) - 1
def midpoint(self, i, xfin):
trans = self.transitions + [xfin]
return (trans[i+1] + trans[i])/2
def start(self, i):
return self.transitions[i]
| 26.658537 | 76 | 0.590119 | 147 | 1,093 | 4.29932 | 0.401361 | 0.118671 | 0.03481 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.005089 | 0.280878 | 1,093 | 40 | 77 | 27.325 | 0.798982 | 0.186642 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.269231 | false | 0 | 0.038462 | 0.115385 | 0.576923 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
6e2cfb49de30b8e3ffc886cb710bf361ce04ad3a | 919 | py | Python | Demo/liaoxf/rational.py | felix9064/PythonProject | bbe4607ba8bf6a188ab01cf16f8b39b5938079e4 | [
"MIT"
] | null | null | null | Demo/liaoxf/rational.py | felix9064/PythonProject | bbe4607ba8bf6a188ab01cf16f8b39b5938079e4 | [
"MIT"
] | null | null | null | Demo/liaoxf/rational.py | felix9064/PythonProject | bbe4607ba8bf6a188ab01cf16f8b39b5938079e4 | [
"MIT"
] | null | null | null | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# 有理数的四则运算
class Rational:
def __init__(self, p, q):
self.p = p
self.q = q
self.gys = Rational.gcb(p, q)
@classmethod
def gcb(cls, a, b):
while b:
a, b = b, a % b
return a
def __str__(self):
a, b = self.p, self.q
while b:
a, b = b, a % b
return "%s/%s" % (self.p / a, self.q / a)
def __add__(self, r):
return Rational(self.p * r.q + self.q * r.p, self.q * r.q)
def __sub__(self, r):
return Rational(self.p * r.q - self.q * r.p, self.q * r.q)
def __mul__(self, r):
return Rational(self.p * r.p, self.q * r.q)
def __truediv__(self, r):
return Rational(self.p * r.q, self.q * r.p)
r1 = Rational(1, 2)
r2 = Rational(1, 4)
print(Rational.gcb(49, 35))
print(r1 + r2)
print(r1 - r2)
print(r1 * r2)
print(r1 / r2)
| 19.145833 | 66 | 0.503808 | 156 | 919 | 2.814103 | 0.24359 | 0.102506 | 0.082005 | 0.173121 | 0.512528 | 0.512528 | 0.512528 | 0.430524 | 0.353075 | 0.271071 | 0 | 0.032415 | 0.328618 | 919 | 47 | 67 | 19.553191 | 0.679092 | 0.056583 | 0 | 0.133333 | 0 | 0 | 0.005787 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.233333 | false | 0 | 0 | 0.133333 | 0.466667 | 0.166667 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 3 |
6e3d9414538603f035db7ed9b10628d96f3a3b3e | 2,673 | py | Python | dpymenus/page.py | Hajime8673/dpymenus | 8a709c7e119569f071dcfa0c53dd2afaca0c36cd | [
"MIT"
] | null | null | null | dpymenus/page.py | Hajime8673/dpymenus | 8a709c7e119569f071dcfa0c53dd2afaca0c36cd | [
"MIT"
] | null | null | null | dpymenus/page.py | Hajime8673/dpymenus | 8a709c7e119569f071dcfa0c53dd2afaca0c36cd | [
"MIT"
] | 1 | 2021-03-26T17:37:19.000Z | 2021-03-26T17:37:19.000Z | from typing import Callable, List
from discord import Embed
class Page(Embed):
"""Represents a single page inside a menu."""
__slots__ = (*Embed.__slots__, '_index', '_buttons_list', '_on_next_event', '_on_fail_event', '_on_cancel_event', '_on_timeout_event')
def __init__(self, **kwargs):
super().__init__(**kwargs)
def __repr__(self):
return f"Page(title={self.title} " \
f"{''.join([f'{k}={v}' for k, v in {j: getattr(self, j) for j in self.__slots__}])})"
def __str__(self):
return f'Page {self.index} {self.title}'
@property
def index(self) -> int:
return getattr(self, '_index', 0)
@index.setter
def index(self, i: int):
self._index = i
@property
def buttons_list(self) -> List:
return getattr(self, '_buttons_list', [])
def buttons(self, buttons: List) -> 'Page':
"""Generates reaction buttons when the page is displayed. Returns itself for fluent-style chaining."""
self._buttons_list = buttons
return self
@property
def on_next_event(self) -> Callable:
return getattr(self, '_on_next_event', None)
def on_next(self, func: Callable) -> 'Page':
"""Sets the function that will be called when the `next` event runs. Returns itself for fluent-style chaining."""
self._on_next_event = func
return self
@property
def on_fail_event(self) -> Callable:
return getattr(self, '_on_fail_event', None)
def on_fail(self, func: Callable) -> 'Page':
"""Sets the function that will be called when the `fail` event runs. Returns itself for fluent-style chaining."""
self._on_fail_event = func
return self
@property
def on_cancel_event(self) -> Callable:
return getattr(self, '_on_cancel_event', None)
def on_cancel(self, func: Callable) -> 'Page':
"""Sets the function that will be called when the `cancel` event runs. Returns itself for fluent-style chaining."""
self._on_cancel_event = func
return self
@property
def on_timeout_event(self) -> Callable:
return getattr(self, '_on_timeout_event', None)
def on_timeout(self, func: Callable) -> 'Page':
"""Sets the function that will be called when the `timeout` event runs. Returns itself for fluent-style chaining."""
self._on_timeout_event = func
return self
def as_safe_embed(self) -> 'Page':
"""Returns a page stripped of Callables and Page-specific properties so we can send it as a standard Embed."""
safe_embed = self.to_dict()
return Embed.from_dict(safe_embed)
| 32.204819 | 138 | 0.643472 | 358 | 2,673 | 4.547486 | 0.226257 | 0.02457 | 0.062654 | 0.067568 | 0.45086 | 0.436732 | 0.436732 | 0.265356 | 0.265356 | 0.265356 | 0 | 0.000493 | 0.240928 | 2,673 | 82 | 139 | 32.597561 | 0.801873 | 0.253648 | 0 | 0.22 | 0 | 0.02 | 0.163349 | 0.011741 | 0 | 0 | 0 | 0 | 0 | 1 | 0.32 | false | 0 | 0.04 | 0.16 | 0.68 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
6e482867e4b79b424a1f417b53f7c979e260c9b5 | 203 | py | Python | rapinator/fake_app.py | dremok/rapinator | 34f25df31fa3b6e3cc878996fd21e37a56f7b2fe | [
"MIT"
] | null | null | null | rapinator/fake_app.py | dremok/rapinator | 34f25df31fa3b6e3cc878996fd21e37a56f7b2fe | [
"MIT"
] | null | null | null | rapinator/fake_app.py | dremok/rapinator | 34f25df31fa3b6e3cc878996fd21e37a56f7b2fe | [
"MIT"
] | null | null | null | import falcon
from rapinator.model.static_model import StaticModel
from rapinator.resources.song import SongResource
api = falcon.API()
song = SongResource(StaticModel())
api.add_route('/song', song)
| 20.3 | 52 | 0.79803 | 26 | 203 | 6.153846 | 0.5 | 0.1625 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.103448 | 203 | 9 | 53 | 22.555556 | 0.879121 | 0 | 0 | 0 | 0 | 0 | 0.024631 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.5 | 0 | 0.5 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
28215c256e31af714435a6df994834ea10042494 | 15,652 | py | Python | methods.py | zsmn/numerical_methods | bbfc62deafc2cfc4cf3f1c401494abccf0d1c240 | [
"MIT"
] | 2 | 2019-11-27T22:43:39.000Z | 2020-10-18T00:53:43.000Z | methods.py | zsmn/numerical_methods | bbfc62deafc2cfc4cf3f1c401494abccf0d1c240 | [
"MIT"
] | null | null | null | methods.py | zsmn/numerical_methods | bbfc62deafc2cfc4cf3f1c401494abccf0d1c240 | [
"MIT"
] | 1 | 2019-12-13T20:56:39.000Z | 2019-12-13T20:56:39.000Z | import math
import sympy as sym
import matplotlib.pyplot as graphic
from sympy.parsing.sympy_parser import parse_expr
pts_y = [] # resultados
pts_t = [] # passos
y, t = sym.symbols('y t')
consts_bashforth = [
[1.0],
[3.0/2.0,-1.0/2.0],
[23.0/12.0,-4.0/3.0,5.0/12.0],
[55.0/24.0,-59.0/24.0,37.0/24.0,-3.0/8.0],
[1901.0/720.0,-1387.0/360.0,109.0/30.0,-637.0/360.0,251.0/720.0],
[4277.0/1440.0,-2641.0/480.0,4991.0/720.0,-3649.0/720.0,959.0/480.0,-95.0/288.0],
[198721.0/60480.0,-18637.0/2520.0,235183.0/20160.0,-10754.0/945.0,135713.0/20160.0,-5603.0/2520.0,19087.0/60480.0],
[16083.0/4480.0,-1152169.0/120960.0,242653.0/13440.0,-296053.0/13440.0,2102243.0/120960.0,-115747.0/13440.0,32863.0/13440.0,-5257.0/17280.0]
]
consts_multon = [
[1.0],
[1.0/2.0,1.0/2.0],
[5.0/12.0,2.0/3.0,-1.0/12.0],
[3.0/8.0,19.0/24.0,-5.0/24.0,1.0/24.0],
[251.0/720.0,323.0/360.0,-11.0/30.0,53.0/360.0,-19.0/720.0],
[95.0/288.0,1427.0/1440.0,-133.0/240.0,241.0/720.0,-173.0/1440.0,3.0/160.0],
[19087.0/60480.0,2713.0/2520.0,-15487.0/20160.0,586.0/945.0,-6737.0/20160.0,263.0/2520.0,-863.0/60480.0],
[5257.0/17280.0,139849.0/120960.0,-4511.0/4480.0,123133.0/120960.0,-88547.0/120960.0,1537.0/4480.0,-11351.0/120960.0,275.0/24192.0]
]
consts_inversa_before = [
[1.0],
[4.0/3.0, -1.0/3.0],
[18.0/11.0, -9.0/11.0, 2.0/11.0],
[48.0/25.0,-36.0/25.0,16.0/25.0,-3.0/25.0],
[300.0/137.0,-300.0/137.0,200.0/137.0,-75.0/137.0,12.0/137.0],
[360.0/147.0,-450.0/147.0,400.0/147.0,-225.0/147.0,72.0/147.0,-10.0/147.0]
]
consts_inversa_after = [
[1.0],
[2.0/3.0],
[6.0/11.0],
[12.0/25.0],
[60.0/137.0],
[60.0/147.0]
]
def plotGraphic(method, arrt, arry, color):
graphic.title(method)
graphic.xlabel("Passos")
graphic.ylabel("f(t, y)")
graphic.plot(arrt, arry, color)
graphic.show()
return
def euler(funct, y0, t0, qt_it, h, printar):
if(printar):
print('Euler')
print('y({}) = {}'.format(t0, y0))
print('it = {}'.format(qt_it))
print('h = {}'.format(h))
f = parse_expr(funct)
arrt = []
arry = []
arrt.append(float(t0))
arry.append(float(y0))
for i in range(1, int(qt_it)+2):
if(printar): print(i-1, ' ', arry[i-1])
arry.append(arry[i-1] + float(h) * f.subs(t, arrt[i-1]).subs(y, arry[i-1]))
arrt.append(arrt[i-1] + float(h))
return arry, arrt
def reverse_euler(funct, y0, t0, qt_it, h, printar):
if(printar):
print('Reverse Euler')
print('y({}) = {}'.format(t0, y0))
print('it = {}'.format(qt_it))
print('h = {}'.format(h))
f = parse_expr(funct)
arrt = []
arry = []
arrt.append(float(t0))
arry.append(float(y0))
for i in range(0, int(qt_it) + 1):
if(printar): print(i, ' ', arry[i])
yaux = arry[i] + float(h) * f.subs(t, arrt[i]).subs(y, arry[i])
taux = arrt[i] + float(h)
arry.append(arry[i] + float(h) * f.subs(t, taux).subs(y, yaux))
arrt.append(arrt[i] + float(h))
return arry, arrt
def aprimorated_euler(funct, y0, t0, qt_it, h, printar):
if(printar):
print('Aprimorated Euler')
print('y({}) = {}'.format(t0, y0))
print('it = {}'.format(qt_it))
print('h = {}'.format(h))
f = parse_expr(funct)
arrt = []
arry = []
arrt.append(float(t0))
arry.append(float(y0))
for i in range(1, int(qt_it)+2):
if(printar): print(i - 1, ' ', arry[i-1])
k1 = f.subs(t, arrt[i-1]).subs(y, arry[i-1])
k2 = f.subs(t, arrt[i-1]+float(h)).subs(y, arry[i-1] + float(h) * k1)
arry.append(arry[i-1] + (float(h)/2) * (k1 + k2))
arrt.append(arrt[i-1] + float(h))
return arry, arrt
def runge_kutta(funct, y0, t0, qt_it, h, printar):
if(printar):
print('Runge Kutta')
print('y({}) = {}'.format(t0, y0))
print('it = {}'.format(qt_it))
print('h = {}'.format(h))
f = parse_expr(funct)
arrt = []
arry = []
arrt.append(float(t0))
arry.append(float(y0))
for i in range(1, int(qt_it)+2):
if(printar): print(i - 1, ' ', arry[i-1])
k1 = f.subs(t, arrt[i-1]).subs(y, arry[i-1])
k2 = f.subs(t, arrt[i-1] + 0.5 * float(h)).subs(y, arry[i-1] + 0.5 * float(h) * k1)
k3 = f.subs(t, arrt[i-1] + 0.5 * float(h)).subs(y, arry[i-1] + 0.5 * float(h) * k2)
k4 = f.subs(t, arrt[i-1] + float(h)).subs(y, arry[i-1] + float(h) * k3)
arry.append(arry[i-1] + (float(h)/6) * (k1 + (2*k2) + (2*k3) + k4))
arrt.append(arrt[i-1] + float(h))
return arry, arrt
def bashfort_dynamic_prevision(funct, vety, tf, h, ordem):
aux = 0.0
yf = vety[len(vety) - 1]
f = parse_expr(funct)
for j in range(len(consts_bashforth[int(ordem) - 1])):
aux += float(h) * consts_bashforth[int(ordem) - 1][j] * f.subs(t, float(tf) - (float(h) * j)).subs(y, float(vety[len(vety) - j - 1]))
yf = yf + aux
return yf
def adam_multon(funct, vety, vett, qt_it, h, ordem, complemento = ''):
print('Adam Multon', complemento)
print('it = {}'.format(qt_it))
print('h = {}'.format(h))
f = parse_expr(funct)
arrt = vett
arry = vety
for i in range(len(arry)):
print(i, ' ', arry[i])
for i in range(int(ordem), int(qt_it) + 1, 1):
aux = 0.0
# calculando com ajuda de bashforth
pd_term = float(h) * consts_multon[int(ordem) - 1][0] * f.subs(t, float(arrt[len(arrt) - 1]) + float(h)).subs(y, bashfort_dynamic_prevision(funct, arry, arrt[len(arrt) - 1], h, ordem))
aux += pd_term
for j in range(1, len(consts_multon[int(ordem) - 1]), 1):
aux += float(h) * consts_multon[int(ordem) - 1][j] * f.subs(t, arrt[len(arrt) - 1] - (float(h) * (j - 1))).subs(y, arry[len(arry) - (j - 1) - 1])
arry.append(float(arry[len(arry) - 1]) + aux)
arrt.append(float(arrt[len(arrt) - 1]) + float(h))
print(i, ' ', arry[len(arry) - 1])
return arry, arrt
def adam_bashforth(funct, vety, vett, qt_it, h, ordem, complemento = ''):
print('Adam Bashforth', complemento)
print('it = {}'.format(qt_it))
print('h = {}'.format(h))
f = parse_expr(funct)
arrt = vett
arry = vety
for i in range(len(arry)):
print(i, ' ', arry[i])
for i in range(int(ordem), int(qt_it) + 1, 1):
aux = 0.0
for j in range(0, len(consts_bashforth[int(ordem) - 1]), 1):
aux += float(h) * consts_bashforth[int(ordem) - 1][j] * f.subs(t, arrt[i - 1] - (float(h) * j)).subs(y, arry[len(arry) - j - 1])
arry.append(float(arry[i - 1]) + aux)
arrt.append(float(arrt[i - 1]) + float(h))
print(i, ' ', arry[i])
return arry, arrt
def formula_inversa(funct, vety, vett, qt_it, h, ordem, complemento = ''):
print('Formula Inversa', complemento)
print('it = {}'.format(qt_it))
print('h = {}'.format(h))
f = parse_expr(funct)
arrt = vett
arry = vety
for i in range(len(arry)):
print(i, ' ', arry[i])
for i in range(int(ordem), int(qt_it) + 1, 1):
aux = 0.0
# previsao com bashforth
aux += float(h) * consts_inversa_after[int(ordem) - 1][0] * f.subs(y, bashfort_dynamic_prevision(funct, arry, arrt[len(arrt) - 1], h, ordem)).subs(t, arrt[i - 1] + float(h))
for j in range(0, len(consts_inversa_before[int(ordem) - 1]), 1):
aux += consts_inversa_before[int(ordem) - 1][j] * arry[len(arry) - j - 1]
arry.append(aux)
arrt.append(float(arrt[i - 1]) + float(h))
print(i, ' ', arry[i])
return arry, arrt
def main():
arq = open('input.txt', 'r')
for linha in arq:
param = linha.split()
if(param[0] == "euler"):
pts_y, pts_t = euler(param[5], param[1], param[2], param[4], param[3], True)
plotGraphic("Euler", pts_t, pts_y, 'red')
elif(param[0] == "euler_inverso"):
pts_y, pts_t = reverse_euler(param[5], param[1], param[2], param[4], param[3], True)
plotGraphic("Euler Inverso", pts_t, pts_y, 'yellow')
elif(param[0] == "euler_aprimorado"):
pts_y, pts_t = aprimorated_euler(param[5], param[1], param[2], param[4], param[3], True)
plotGraphic("Euler Aprimorado", pts_t, pts_y, 'blue')
elif(param[0] == "runge_kutta"):
pts_y, pts_t = runge_kutta(param[5], param[1], param[2], param[4], param[3], True)
plotGraphic("Runge Kutta", pts_t, pts_y, 'black')
elif("adam_multon" in param[0]):
if("by_euler_inverso" in param[0]):
pts_y, pts_t = reverse_euler(param[len(param) - 2], param[1], param[2], int(param[len(param) - 1]) - 2, param[3], False)
pts_y, pts_t = adam_multon(param[len(param) - 2], pts_y, pts_t, param[len(param) - 3], param[len(param) - 4], param[len(param) - 1], ' by Euler Inverso')
plotGraphic("Adam Multon by Euler Inverso", pts_t, pts_y, 'cyan')
elif("by_euler_aprimorado" in param[0]):
pts_y, pts_t = aprimorated_euler(param[len(param) - 2], param[1], param[2], int(param[len(param) - 1]) - 2, param[3], False)
pts_y, pts_t = adam_multon(param[len(param) - 2], pts_y, pts_t, param[len(param) - 3], param[len(param) - 4], param[len(param) - 1], ' by Euler Aprimorado')
plotGraphic("Adam Multon by Euler Aprimorado", pts_t, pts_y, 'cyan')
elif("by_runge_kutta" in param[0]):
pts_y, pts_t = runge_kutta(param[len(param) - 2], param[1], param[2], int(param[len(param) - 1]) - 2, param[3], False)
pts_y, pts_t = adam_multon(param[len(param) - 2], pts_y, pts_t, param[len(param) - 3], param[len(param) - 4], param[len(param) - 1], ' by Runge Kutta')
plotGraphic("Adam Multon by Runge Kutta", pts_t, pts_y, 'cyan')
elif("by_euler" in param[0]):
pts_y, pts_t = euler(param[len(param) - 2], param[1], param[2], int(param[len(param) - 1]) - 2, param[3], False)
pts_y, pts_t = adam_multon(param[len(param) - 2], pts_y, pts_t, param[len(param) - 3], param[len(param) - 4], param[len(param) - 1], ' by Euler')
plotGraphic("Adam Multon by Euler", pts_t, pts_y, 'cyan')
else:
pts_y = []
pts_t = []
h_aux = 0
for i in range(int(param[len(param) - 1]) - 1):
pts_y.append(float(param[i+1]))
pts_t.append(float(param[len(param) - 4]) + h_aux)
h_aux = h_aux + float(param[len(param) - 4])
pts_y, pts_t = adam_multon(param[len(param) - 2], pts_y, pts_t, param[len(param) - 3], param[len(param) - 4], param[len(param) - 1])
plotGraphic("Adam Multon", pts_t, pts_y, 'cyan')
elif("adam_bashforth" in param[0]):
if("by_euler_inverso" in param[0]):
pts_y, pts_t = reverse_euler(param[len(param) - 2], param[1], param[2], int(param[len(param) - 1]) - 2, param[3], False)
pts_y, pts_t = adam_bashforth(param[len(param) - 2], pts_y, pts_t, param[len(param) - 3], param[len(param) - 4], param[len(param) - 1], ' by Euler Inverso')
plotGraphic("Adam Bashforth by Euler Inverso", pts_t, pts_y, 'brown')
elif("by_euler_aprimorado" in param[0]):
pts_y, pts_t = aprimorated_euler(param[len(param) - 2], param[1], param[2], int(param[len(param) - 1]) - 2, param[3], False)
pts_y, pts_t = adam_bashforth(param[len(param) - 2], pts_y, pts_t, param[len(param) - 3], param[len(param) - 4], param[len(param) - 1], ' by Euler Aprimorado')
plotGraphic("Adam Bashforth by Euler Aprimorado", pts_t, pts_y, 'brown')
elif("by_runge_kutta" in param[0]):
pts_y, pts_t = runge_kutta(param[len(param) - 2], param[1], param[2], int(param[len(param) - 1]) - 2, param[3], False)
pts_y, pts_t = adam_bashforth(param[len(param) - 2], pts_y, pts_t, param[len(param) - 3], param[len(param) - 4], param[len(param) - 1], ' by Runge Kutta')
plotGraphic("Adam Bashforth by Runge Kutta", pts_t, pts_y, 'brown')
elif("by_euler" in param[0]):
pts_y, pts_t = euler(param[len(param) - 2], param[1], param[2], int(param[len(param) - 1]) - 2, param[3], False)
pts_y, pts_t = adam_bashforth(param[len(param) - 2], pts_y, pts_t, param[len(param) - 3], param[len(param) - 4], param[len(param) - 1], ' by Euler')
plotGraphic("Adam Bashforth by Euler", pts_t, pts_y, 'brown')
else:
pts_y = []
pts_t = []
h_aux = 0
for i in range(int(param[len(param) - 1])):
pts_y.append(float(param[i+1]))
pts_t.append(float(param[len(param) - 4]) + h_aux)
h_aux = h_aux + float(param[len(param) - 4])
pts_y, pts_t = adam_bashforth(param[len(param) - 2], pts_y, pts_t, param[len(param) - 3], param[len(param) - 4], param[len(param) - 1])
plotGraphic("Adam Bashforth", pts_t, pts_y, 'brown')
elif("formula_inversa" in param[0]):
if("by_euler_inverso" in param[0]):
pts_y, pts_t = reverse_euler(param[len(param) - 2], param[1], param[2], int(param[len(param) - 1]) - 2, param[3], False)
pts_y, pts_t = formula_inversa(param[len(param) - 2], pts_y, pts_t, param[len(param) - 3], param[len(param) - 4], param[len(param) - 1], ' by Euler Inverso')
plotGraphic("Formula Inversa by Euler Inverso", pts_t, pts_y, 'silver')
elif("by_euler_aprimorado" in param[0]):
pts_y, pts_t = aprimorated_euler(param[len(param) - 2], param[1], param[2], int(param[len(param) - 1]) - 2, param[3], False)
pts_y, pts_t = formula_inversa(param[len(param) - 2], pts_y, pts_t, param[len(param) - 3], param[len(param) - 4], param[len(param) - 1], ' by Euler Aprimorado')
plotGraphic("Formula Inversaby Euler Aprimorado", pts_t, pts_y, 'silver')
elif("by_runge_kutta" in param[0]):
pts_y, pts_t = runge_kutta(param[len(param) - 2], param[1], param[2], int(param[len(param) - 1]) - 2, param[3], False)
pts_y, pts_t = formula_inversa(param[len(param) - 2], pts_y, pts_t, param[len(param) - 3], param[len(param) - 4], param[len(param) - 1], ' by Runge Kutta')
plotGraphic("Formula Inversa by Runge Kutta", pts_t, pts_y, 'silver')
elif("by_euler" in param[0]):
pts_y, pts_t = euler(param[len(param) - 2], param[1], param[2], int(param[len(param) - 1]) - 2, param[3], False)
pts_y, pts_t = formula_inversa(param[len(param) - 2], pts_y, pts_t, param[len(param) - 3], param[len(param) - 4], param[len(param) - 1], ' by Euler')
plotGraphic("Formula Inversa by Euler", pts_t, pts_y, 'silver')
else:
pts_y = []
pts_t = []
h_aux = 0
for i in range(int(param[len(param) - 1])):
pts_y.append(float(param[i+1]))
pts_t.append(float(param[len(param) - 4]) + h_aux)
h_aux = h_aux + float(param[len(param) - 4])
pts_y, pts_t = formula_inversa(param[len(param) - 2], pts_y, pts_t, param[len(param) - 3], param[len(param) - 4], param[len(param) - 1])
plotGraphic("Formula Inversa", pts_t, pts_y, 'silver')
main() | 44.339943 | 192 | 0.550856 | 2,585 | 15,652 | 3.2294 | 0.080077 | 0.089123 | 0.144825 | 0.046957 | 0.791806 | 0.754193 | 0.716339 | 0.652971 | 0.635721 | 0.631049 | 0 | 0.094636 | 0.251981 | 15,652 | 353 | 193 | 44.339943 | 0.618381 | 0.004728 | 0 | 0.496454 | 0 | 0 | 0.077822 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.035461 | false | 0.003546 | 0.014184 | 0 | 0.08156 | 0.152482 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
282911b2877cf0fe4ff15ea12f483e14e03b127e | 188 | py | Python | python_interview_code/code/3_python_basics/exc.py | youaresherlock/PythonPractice | 2e22d3fdcb26353cb0d8215c150e84d11bc9a022 | [
"Apache-2.0"
] | null | null | null | python_interview_code/code/3_python_basics/exc.py | youaresherlock/PythonPractice | 2e22d3fdcb26353cb0d8215c150e84d11bc9a022 | [
"Apache-2.0"
] | null | null | null | python_interview_code/code/3_python_basics/exc.py | youaresherlock/PythonPractice | 2e22d3fdcb26353cb0d8215c150e84d11bc9a022 | [
"Apache-2.0"
] | 1 | 2019-11-05T01:10:15.000Z | 2019-11-05T01:10:15.000Z | #!usr/bin/python
# -*- coding:utf8 -*-
class MyException(Exception):
pass
try:
raise MyException('my exception')
# exception MyException as e:
except Exception as e:
print(e) | 17.090909 | 37 | 0.680851 | 24 | 188 | 5.333333 | 0.666667 | 0.046875 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.006536 | 0.18617 | 188 | 11 | 38 | 17.090909 | 0.830065 | 0.335106 | 0 | 0 | 0 | 0 | 0.097561 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0.166667 | 0 | 0 | 0.166667 | 0.166667 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 3 |
284251c42dd0bc47544403486c8ea455c0596b72 | 733 | py | Python | dadata/standartization.py | f213/dadata-client | dbd619d752a96bc0d48be51e07b53e8f9a795079 | [
"MIT"
] | 8 | 2018-06-11T13:35:30.000Z | 2021-11-12T12:17:52.000Z | dadata/standartization.py | f213/dadata-client | dbd619d752a96bc0d48be51e07b53e8f9a795079 | [
"MIT"
] | 74 | 2018-06-12T17:29:15.000Z | 2020-05-18T02:13:36.000Z | dadata/standartization.py | f213/dadata-client | dbd619d752a96bc0d48be51e07b53e8f9a795079 | [
"MIT"
] | 2 | 2018-06-12T16:05:37.000Z | 2018-08-05T21:39:18.000Z | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from dadata.base_client import DadataBasePaidClient
class DadataAddressStandartizationClient(DadataBasePaidClient):
"""DaData address standartization client."""
API_URL = 'https://dadata.ru/api/v2/clean/address'
def request(self, source):
"""Send request to standartization API and return result data if
provided."""
return super(DadataAddressStandartizationClient, self).request([source])
def _prepare_response(self, respose):
try:
return super(DadataAddressStandartizationClient, self) \
._prepare_response(respose)[0] or None
except (IndexError, KeyError):
return
| 31.869565 | 80 | 0.694407 | 71 | 733 | 7.014085 | 0.633803 | 0.044177 | 0.180723 | 0.196787 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.005199 | 0.212824 | 733 | 22 | 81 | 33.318182 | 0.857886 | 0.181446 | 0 | 0 | 0 | 0 | 0.065404 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.166667 | false | 0 | 0.166667 | 0 | 0.75 | 0 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
28517b5f9e53ef07cad7013125d08600235652df | 21 | py | Python | chroniclr/version.py | NBurley93/Chroniclr | 4ad97f0fb3ebeee0f805347bba735f33671928c4 | [
"MIT"
] | null | null | null | chroniclr/version.py | NBurley93/Chroniclr | 4ad97f0fb3ebeee0f805347bba735f33671928c4 | [
"MIT"
] | 5 | 2018-08-06T13:50:22.000Z | 2018-08-06T14:20:19.000Z | chroniclr/version.py | NBurley93/Chroniclr | 4ad97f0fb3ebeee0f805347bba735f33671928c4 | [
"MIT"
] | null | null | null | APP_VERSION = '1.0.0' | 21 | 21 | 0.666667 | 5 | 21 | 2.6 | 0.8 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.157895 | 0.095238 | 21 | 1 | 21 | 21 | 0.526316 | 0 | 0 | 0 | 0 | 0 | 0.227273 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
2857882a1eb3f1009e36dd9e7504c9a5f33901e5 | 21 | py | Python | examples/utils/project_settings.py | pichatelli/simple-settings | b0cb539a13581107effc674c823703e990e3463c | [
"MIT"
] | 213 | 2015-05-13T21:29:35.000Z | 2022-02-24T12:56:00.000Z | examples/utils/project_settings.py | pichatelli/simple-settings | b0cb539a13581107effc674c823703e990e3463c | [
"MIT"
] | 248 | 2015-05-13T23:32:16.000Z | 2022-02-02T21:41:30.000Z | examples/utils/project_settings.py | pichatelli/simple-settings | b0cb539a13581107effc674c823703e990e3463c | [
"MIT"
] | 39 | 2015-05-18T21:29:42.000Z | 2022-03-26T16:27:46.000Z | SOME_SETTING = 'bar'
| 10.5 | 20 | 0.714286 | 3 | 21 | 4.666667 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.142857 | 21 | 1 | 21 | 21 | 0.777778 | 0 | 0 | 0 | 0 | 0 | 0.142857 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
2863a347fd23a8bee21de91a29caf31aeb2ec17c | 1,271 | py | Python | doe-traits.py | pettitpeon/doe-nft-traits | d05aee512364dfa0301ee859fecf524e7f1d2094 | [
"MIT"
] | null | null | null | doe-traits.py | pettitpeon/doe-nft-traits | d05aee512364dfa0301ee859fecf524e7f1d2094 | [
"MIT"
] | null | null | null | doe-traits.py | pettitpeon/doe-nft-traits | d05aee512364dfa0301ee859fecf524e7f1d2094 | [
"MIT"
] | null | null | null | import json
with open('json/ipfs_doe_nft_metadata.json') as metadata_f:
data = json.loads(metadata_f.read())
traits = {}
# Generate traits list
for asset in data['assets']:
for trait in asset['attributes']:
if trait['trait_type'] not in traits:
traits[trait['trait_type']] = {'total_count': 1}
traits[trait['trait_type']]['values_count'] = 0
traits[trait['trait_type']]['values'] = {}
else:
traits[trait['trait_type']]['total_count'] = traits[trait['trait_type']]['total_count'] + 1
if trait['value'] not in traits[trait['trait_type']]['values']:
traits[trait['trait_type']]['values'][trait['value']] = 1
traits[trait['trait_type']]['values_count'] = traits[trait['trait_type']]['values_count'] + 1
else:
traits[trait['trait_type']]['values'][trait['value']] = traits[trait['trait_type']]['values'][trait['value']] + 1
# Sort traits' values by rarity
for trait in traits:
traits[trait]['values'] = dict(sorted(traits[trait]['values'].items(), key=lambda item: item[1]))
with open('json/doe_nft_traits.json', 'w') as traits_f:
json.dump(traits, traits_f)
| 43.827586 | 129 | 0.585366 | 159 | 1,271 | 4.509434 | 0.27044 | 0.199442 | 0.23431 | 0.306834 | 0.495119 | 0.411437 | 0.32636 | 0.103208 | 0 | 0 | 0 | 0.007239 | 0.239182 | 1,271 | 28 | 130 | 45.392857 | 0.73423 | 0.039339 | 0 | 0.095238 | 1 | 0 | 0.265189 | 0.045156 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.047619 | 0 | 0.047619 | 0 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
28695ad7539c2ea948492bc9b02c354f9686a37c | 263 | py | Python | src/tox_ansible/_yaml.py | strider/tox-ansible | e5963fac18b788d450c0b827538b54354e261fce | [
"MIT"
] | 7 | 2020-10-10T13:58:39.000Z | 2021-04-17T14:57:59.000Z | src/tox_ansible/_yaml.py | strider/tox-ansible | e5963fac18b788d450c0b827538b54354e261fce | [
"MIT"
] | 52 | 2020-08-19T16:44:08.000Z | 2021-08-31T13:34:02.000Z | src/tox_ansible/_yaml.py | strider/tox-ansible | e5963fac18b788d450c0b827538b54354e261fce | [
"MIT"
] | 5 | 2020-08-19T19:02:03.000Z | 2021-04-14T04:17:44.000Z | from yaml import load
try:
from yaml import CLoader as Loader
except ImportError: # pragma: no cover
from yaml import Loader # type: ignore
def load_yaml(filename: str):
with open(filename, "r") as c:
return load(c.read(), Loader=Loader)
| 21.916667 | 44 | 0.684411 | 39 | 263 | 4.589744 | 0.615385 | 0.134078 | 0.234637 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.228137 | 263 | 11 | 45 | 23.909091 | 0.881773 | 0.110266 | 0 | 0 | 0 | 0 | 0.004329 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.125 | false | 0 | 0.5 | 0 | 0.75 | 0 | 0 | 0 | 0 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
28758efbdaedcc7a280aaf04878ed300240285a4 | 1,014 | py | Python | src/modelo/gasto.py | CamiloPMISO/test-ci | 4ee3715cb10456d41ebe4ec53128f7c16369ef16 | [
"MIT"
] | null | null | null | src/modelo/gasto.py | CamiloPMISO/test-ci | 4ee3715cb10456d41ebe4ec53128f7c16369ef16 | [
"MIT"
] | null | null | null | src/modelo/gasto.py | CamiloPMISO/test-ci | 4ee3715cb10456d41ebe4ec53128f7c16369ef16 | [
"MIT"
] | null | null | null | from sqlalchemy import Column, Integer, String, Boolean, Float , Date, ForeignKey
from src.modelo.declarative_base import Base
class Gasto(Base):
__tablename__ = 'gasto'
id = Column(Integer, primary_key=True)
concepto = Column(String)
valor = Column(String)
fecha_gasto = Column(Date)
viajero = Column(Integer, ForeignKey('viajero.id'),nullable=False)
actividad = Column(Integer, ForeignKey('actividad.id'),nullable=False)
def dar_concepto(self):
return self.concepto
def cambiar_concepto(self,concepto):
self.concepto = concepto
def dar_valor(self):
return self.valor
def cambiar_valor(self,valor):
self.valor = valor
def dar_fecha_gasto(self):
return self.fecha_gasto.strftime("%d-%m-%Y")
def cambiar_fecha_gasto(self,fecha_gasto):
self.fecha_gasto = fecha_gasto
def dar_viajero(self):
return self.viajero
def cambiar_viajero(self,id_viajero):
self.viajero = id_viajero | 28.166667 | 81 | 0.685404 | 126 | 1,014 | 5.333333 | 0.293651 | 0.104167 | 0.083333 | 0.056548 | 0.056548 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.215976 | 1,014 | 36 | 82 | 28.166667 | 0.845283 | 0 | 0 | 0 | 0 | 0 | 0.034483 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.307692 | false | 0 | 0.076923 | 0.153846 | 0.846154 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
288353ab42c7523d751488a0319919f2b1f510ee | 333 | py | Python | res/PyTorchExamples/examples/normalize/__init__.py | chogba6/ONE | 3d35259f89ee3109cfd35ab6f38c231904487f3b | [
"Apache-2.0"
] | 255 | 2020-05-22T07:45:29.000Z | 2022-03-29T23:58:22.000Z | res/PyTorchExamples/examples/normalize/__init__.py | chogba6/ONE | 3d35259f89ee3109cfd35ab6f38c231904487f3b | [
"Apache-2.0"
] | 5,102 | 2020-05-22T07:48:33.000Z | 2022-03-31T23:43:39.000Z | res/PyTorchExamples/examples/normalize/__init__.py | chogba6/ONE | 3d35259f89ee3109cfd35ab6f38c231904487f3b | [
"Apache-2.0"
] | 120 | 2020-05-22T07:51:08.000Z | 2022-02-16T19:08:05.000Z | import torch
import torch.nn as nn
# model
class net_normalize(nn.Module):
def __init__(self):
super().__init__()
def forward(self, input):
return torch.nn.functional.normalize(input, p=2.0, dim=3, eps=1e-12)
_model_ = net_normalize()
# dummy input for onnx generation
_dummy_ = torch.randn(1, 2, 3, 3)
| 18.5 | 76 | 0.675676 | 51 | 333 | 4.137255 | 0.607843 | 0.104265 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.037453 | 0.198198 | 333 | 17 | 77 | 19.588235 | 0.752809 | 0.111111 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.222222 | false | 0 | 0.222222 | 0.111111 | 0.666667 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
95489305f2be8e7c8ea244d8336001cea90b7115 | 304 | py | Python | proyectodjango/Login/models.py | AnnieLan/Web | 5e901544f9293caa90b1c2ed222c3006b3b498eb | [
"bzip2-1.0.6"
] | null | null | null | proyectodjango/Login/models.py | AnnieLan/Web | 5e901544f9293caa90b1c2ed222c3006b3b498eb | [
"bzip2-1.0.6"
] | null | null | null | proyectodjango/Login/models.py | AnnieLan/Web | 5e901544f9293caa90b1c2ed222c3006b3b498eb | [
"bzip2-1.0.6"
] | null | null | null | from django.db import models
# Create your models here.
class Login (models.Model):
nombre = models.CharField(max_length = 254,null=False)
ap_pat = models.CharField(max_length = 254,null=False)
ap_mat = models.CharField(max_length = 254,null=False)
edad = models.IntegerField(null=False) | 38 | 58 | 0.740132 | 44 | 304 | 5 | 0.522727 | 0.163636 | 0.245455 | 0.327273 | 0.509091 | 0.509091 | 0.509091 | 0.345455 | 0 | 0 | 0 | 0.034884 | 0.151316 | 304 | 8 | 59 | 38 | 0.817829 | 0.078947 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.166667 | 0 | 1 | 0 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
956ddf12fc48ed5d94144c62785cfaff7b74999a | 196 | py | Python | PythonExercicios/Mundo1/ex031.py | leonardocsrod/Python-Curso-em-Video | d61e4f1f0779050d176419de2cec0ef539e48cb3 | [
"MIT"
] | null | null | null | PythonExercicios/Mundo1/ex031.py | leonardocsrod/Python-Curso-em-Video | d61e4f1f0779050d176419de2cec0ef539e48cb3 | [
"MIT"
] | null | null | null | PythonExercicios/Mundo1/ex031.py | leonardocsrod/Python-Curso-em-Video | d61e4f1f0779050d176419de2cec0ef539e48cb3 | [
"MIT"
] | null | null | null | distance = int(input('Inform the distance: '))
if distance <= 200:
price = distance * 0.5
else:
price = distance * 0.45
print('Your trip cost \033[1;33;44mR$ {:.2f}\033[m.'.format(price))
| 28 | 67 | 0.637755 | 31 | 196 | 4.032258 | 0.741935 | 0.208 | 0.224 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.123457 | 0.173469 | 196 | 6 | 68 | 32.666667 | 0.648148 | 0 | 0 | 0 | 0 | 0 | 0.331633 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.166667 | 0 | 0 | 0 | null | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
9572e85f956e4a70d791fb40ef026b24c0d2e19a | 183 | py | Python | testsuite/iff/run.py | scott-wilson/oiio | f67cce9b7b8623aca730af0fb2faaafcbe785dde | [
"BSD-3-Clause"
] | 1 | 2021-01-22T21:12:24.000Z | 2021-01-22T21:12:24.000Z | testsuite/iff/run.py | sobotka/oiio | 7f1f1d64933a51e1610da22a26f80528e3dd6dd8 | [
"BSD-3-Clause"
] | null | null | null | testsuite/iff/run.py | sobotka/oiio | 7f1f1d64933a51e1610da22a26f80528e3dd6dd8 | [
"BSD-3-Clause"
] | null | null | null | #!/usr/bin/env python
imagedir = parent + "/oiio-images"
command += oiiotool (imagedir+"/grid.tif --scanline -o grid.iff")
command += diff_command (imagedir+"/grid.tif", "grid.iff")
| 30.5 | 65 | 0.688525 | 25 | 183 | 5 | 0.64 | 0.192 | 0.24 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.10929 | 183 | 5 | 66 | 36.6 | 0.766871 | 0.10929 | 0 | 0 | 0 | 0 | 0.376543 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
958da748d74a13fc37d5a4894c62801091a03b31 | 271 | py | Python | engine/src/hopeit/cli/__init__.py | pcanto-hopeit/hopeit.engine | c17b0438e56940a4d1b2f071cca90ae8b6f70629 | [
"Apache-2.0"
] | 15 | 2020-07-09T17:41:14.000Z | 2021-10-04T20:13:08.000Z | engine/src/hopeit/cli/__init__.py | pcanto-hopeit/hopeit.engine | c17b0438e56940a4d1b2f071cca90ae8b6f70629 | [
"Apache-2.0"
] | 48 | 2020-07-10T15:16:17.000Z | 2022-03-03T19:46:46.000Z | engine/src/hopeit/cli/__init__.py | pcanto-hopeit/hopeit.engine | c17b0438e56940a4d1b2f071cca90ae8b6f70629 | [
"Apache-2.0"
] | 3 | 2020-07-08T20:12:58.000Z | 2021-01-10T15:57:21.000Z | """
hopeit.engine CLI (Command Line Interface) module
provides implementation for the following CLI commands:
* **openapi** (hopeit_openapi): creation, diff and update openapi.json spec files
* **server** (hopeit_server): tool for running a server instance
"""
| 30.111111 | 85 | 0.734317 | 34 | 271 | 5.794118 | 0.764706 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.162362 | 271 | 8 | 86 | 33.875 | 0.867841 | 0.96679 | 0 | null | 0 | null | 0 | 0 | null | 0 | 0 | 0 | null | 1 | null | true | 0 | 0 | null | null | null | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
959f22014f6428b1086e2f205253c6563287d8b3 | 164 | py | Python | problem_solving/algorithms/strings/q2_camelcase.py | mxdzi/hackerrank | 4455f73e4479a4204b2e1167253f6a02351aa5b7 | [
"MIT"
] | null | null | null | problem_solving/algorithms/strings/q2_camelcase.py | mxdzi/hackerrank | 4455f73e4479a4204b2e1167253f6a02351aa5b7 | [
"MIT"
] | null | null | null | problem_solving/algorithms/strings/q2_camelcase.py | mxdzi/hackerrank | 4455f73e4479a4204b2e1167253f6a02351aa5b7 | [
"MIT"
] | null | null | null | from string import ascii_uppercase
def camelcase(s):
count = 1
for char in s:
if char in ascii_uppercase:
count += 1
return count
| 16.4 | 35 | 0.609756 | 23 | 164 | 4.26087 | 0.652174 | 0.285714 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.018519 | 0.341463 | 164 | 9 | 36 | 18.222222 | 0.888889 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.142857 | false | 0 | 0.142857 | 0 | 0.428571 | 0 | 1 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
95bc255252bfca70a0219b581a9d3ce4da3cd44e | 562 | py | Python | example/dict.py | isprime/marrow.interface | f269772d46b74bb97a1f74dcbd0e33c967010495 | [
"MIT"
] | 2 | 2016-03-22T15:21:48.000Z | 2017-02-21T23:52:46.000Z | example/dict.py | isprime/marrow.interface | f269772d46b74bb97a1f74dcbd0e33c967010495 | [
"MIT"
] | 1 | 2019-01-21T22:09:00.000Z | 2019-01-21T22:09:00.000Z | example/dict.py | isprime/marrow.interface | f269772d46b74bb97a1f74dcbd0e33c967010495 | [
"MIT"
] | 2 | 2015-12-21T03:24:06.000Z | 2016-11-10T15:19:27.000Z | # encoding: utf-8
from marrow.interface import Interface
from marrow.interface.schema import Method
try:
from collections import UserDict
except ImportError:
from UserDict import UserDict
__all__ = ['IDictionary']
class IDictionary(Interface):
__assume_interface__ = (dict, )
__getitem__ = Method(args=1)
__setitem__ = Method(args=2)
__delitem__ = Method(args=1)
assert isinstance(dict, IDictionary)
assert isinstance(dict(), IDictionary)
assert isinstance(UserDict, IDictionary)
assert isinstance(UserDict(), IDictionary)
| 19.37931 | 42 | 0.752669 | 61 | 562 | 6.590164 | 0.442623 | 0.159204 | 0.201493 | 0.154229 | 0.328358 | 0.19403 | 0 | 0 | 0 | 0 | 0 | 0.008493 | 0.161922 | 562 | 28 | 43 | 20.071429 | 0.845011 | 0.02669 | 0 | 0 | 0 | 0 | 0.020183 | 0 | 0 | 0 | 0 | 0 | 0.25 | 1 | 0 | false | 0 | 0.3125 | 0 | 0.625 | 0 | 0 | 0 | 0 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
95d1d22f3c4fb410c11da34cfbab15f6f8a46d5d | 103 | py | Python | kedroio/__init__.py | atsangarides/kedroio | bc678e3b47e1c19076c2d498d3761445bfefeeb1 | [
"MIT"
] | null | null | null | kedroio/__init__.py | atsangarides/kedroio | bc678e3b47e1c19076c2d498d3761445bfefeeb1 | [
"MIT"
] | null | null | null | kedroio/__init__.py | atsangarides/kedroio | bc678e3b47e1c19076c2d498d3761445bfefeeb1 | [
"MIT"
] | null | null | null | import logging
__version__ = "0.1.3"
logging.getLogger("kedro-io").addHandler(logging.NullHandler())
| 17.166667 | 63 | 0.757282 | 13 | 103 | 5.692308 | 0.846154 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.031579 | 0.07767 | 103 | 5 | 64 | 20.6 | 0.747368 | 0 | 0 | 0 | 0 | 0 | 0.126214 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.333333 | 0 | 0.333333 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
95eb02dc2bad1a7dc38f26793a45fc7c4e20dc39 | 20 | py | Python | meerk40t/device/lhystudios/__init__.py | apbarratt/meerk40t | 7049ab7693d482bd96ff3a298a9fc164836a750d | [
"MIT"
] | 118 | 2019-09-09T14:15:28.000Z | 2022-03-17T18:54:27.000Z | meerk40t/device/lhystudios/__init__.py | apbarratt/meerk40t | 7049ab7693d482bd96ff3a298a9fc164836a750d | [
"MIT"
] | 656 | 2019-07-21T03:34:12.000Z | 2022-03-30T18:10:31.000Z | meerk40t/device/lhystudios/__init__.py | apbarratt/meerk40t | 7049ab7693d482bd96ff3a298a9fc164836a750d | [
"MIT"
] | 48 | 2019-12-22T23:05:27.000Z | 2022-03-17T18:54:25.000Z | name = "lhystudios"
| 10 | 19 | 0.7 | 2 | 20 | 7 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.15 | 20 | 1 | 20 | 20 | 0.823529 | 0 | 0 | 0 | 0 | 0 | 0.5 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
251aa82c729a5211542bdc05ab6c9a6f6e6f7d57 | 95 | py | Python | rgbd_seg/models/decoders/registry.py | tomchol/ShapeConv | 41ead20854daed43b59ef978665fa53f113cbb65 | [
"Apache-2.0"
] | 57 | 2021-08-03T08:03:56.000Z | 2022-03-25T12:17:44.000Z | rgbd_seg/models/decoders/registry.py | tomchol/ShapeConv | 41ead20854daed43b59ef978665fa53f113cbb65 | [
"Apache-2.0"
] | 6 | 2021-08-30T10:06:46.000Z | 2022-03-08T12:47:20.000Z | rgbd_seg/models/decoders/registry.py | tomchol/ShapeConv | 41ead20854daed43b59ef978665fa53f113cbb65 | [
"Apache-2.0"
] | 8 | 2021-08-13T08:32:54.000Z | 2022-03-25T11:12:13.000Z | from rgbd_seg.utils import Registry
BRICKS = Registry('brick')
DECODERS = Registry('decoder')
| 19 | 35 | 0.768421 | 12 | 95 | 6 | 0.833333 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.115789 | 95 | 4 | 36 | 23.75 | 0.857143 | 0 | 0 | 0 | 0 | 0 | 0.126316 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.333333 | 0 | 0.333333 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
252036936cf225d38479041e09b29a8d46b67780 | 48 | py | Python | tests/functional/pages/generic/__init__.py | mayank-sfdc/directory-tests | 6e978bc1a27c19389e99e454143122aa27e47b85 | [
"MIT"
] | 4 | 2017-06-02T09:09:10.000Z | 2018-01-25T19:06:12.000Z | tests/functional/pages/generic/__init__.py | mayank-sfdc/directory-tests | 6e978bc1a27c19389e99e454143122aa27e47b85 | [
"MIT"
] | 53 | 2016-10-27T22:31:03.000Z | 2022-03-07T11:18:25.000Z | tests/functional/pages/generic/__init__.py | mayank-sfdc/directory-tests | 6e978bc1a27c19389e99e454143122aa27e47b85 | [
"MIT"
] | 3 | 2017-11-22T11:42:40.000Z | 2022-02-21T01:20:04.000Z | # -*- coding: utf-8 -*-
__all__ = ["not_found"]
| 16 | 23 | 0.541667 | 6 | 48 | 3.5 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.025 | 0.166667 | 48 | 2 | 24 | 24 | 0.5 | 0.4375 | 0 | 0 | 0 | 0 | 0.36 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
25648b08a8b732a90943425b11134774c04f6b50 | 304 | py | Python | runtests.py | theatlantic/django-admin-testutils | 6f30cbf286c26e1c354051fd3fecf8d28403ecd8 | [
"BSD-2-Clause"
] | 1 | 2017-04-25T22:25:38.000Z | 2017-04-25T22:25:38.000Z | runtests.py | theatlantic/django-admin-testutils | 6f30cbf286c26e1c354051fd3fecf8d28403ecd8 | [
"BSD-2-Clause"
] | null | null | null | runtests.py | theatlantic/django-admin-testutils | 6f30cbf286c26e1c354051fd3fecf8d28403ecd8 | [
"BSD-2-Clause"
] | null | null | null | #!/usr/bin/env python
import warnings
import django_admin_testutils
def main():
warnings.simplefilter("error", Warning)
runtests = django_admin_testutils.RunTests(
"django_admin_testutils.tests.settings", "django_admin_testutils")
runtests()
if __name__ == '__main__':
main()
| 20.266667 | 74 | 0.726974 | 34 | 304 | 6.029412 | 0.558824 | 0.214634 | 0.390244 | 0.273171 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.161184 | 304 | 14 | 75 | 21.714286 | 0.803922 | 0.065789 | 0 | 0 | 0 | 0 | 0.254417 | 0.208481 | 0 | 0 | 0 | 0 | 0 | 1 | 0.111111 | false | 0 | 0.222222 | 0 | 0.333333 | 0 | 0 | 0 | 0 | null | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
c270b6f6ed6d43caa78de9eb65a6ddd80961f99f | 23 | py | Python | judgesite/__init__.py | NJUST-FishTeam/OnlineJudgeSite_M6 | 31ef866ea596c0b4889f8118adf5451ba3971c92 | [
"MIT"
] | 18 | 2015-04-13T00:46:59.000Z | 2021-11-16T08:23:58.000Z | judgesite/__init__.py | maemual/OnlineJudgeSite_M6 | 842a39bed52545d78f41835be73eeca23ef28096 | [
"MIT"
] | 5 | 2016-01-09T11:44:34.000Z | 2017-06-04T10:34:24.000Z | judgesite/__init__.py | maemual/OnlineJudgeSite_M6 | 842a39bed52545d78f41835be73eeca23ef28096 | [
"MIT"
] | 2 | 2015-03-23T13:22:02.000Z | 2017-01-06T17:47:47.000Z | __author__ = 'maemual'
| 11.5 | 22 | 0.73913 | 2 | 23 | 6.5 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.130435 | 23 | 1 | 23 | 23 | 0.65 | 0 | 0 | 0 | 0 | 0 | 0.304348 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
c2794f9e47489caf9cf880edb3ee15771873ba23 | 1,888 | py | Python | game_play/db.py | tgruby/dungeon-hunt | f8c636e50e4041817d8c4d07fcbcd853a58b395d | [
"MIT"
] | 3 | 2020-11-23T17:50:22.000Z | 2020-12-14T22:19:12.000Z | game_play/db.py | tgruby/dungeon-hunt | f8c636e50e4041817d8c4d07fcbcd853a58b395d | [
"MIT"
] | 15 | 2020-12-11T13:24:58.000Z | 2020-12-23T09:50:19.000Z | game_play/db.py | tgruby/dungeon-hunt | f8c636e50e4041817d8c4d07fcbcd853a58b395d | [
"MIT"
] | null | null | null | import os
import pickle
from game_play import leader_board
def init_db():
try:
os.mkdir('../data')
except OSError as error:
# supressed due to this is the normal operation. TODO: fix this so we check first before trying to make.
pass
def load_leaderboard():
lb = load('data/leaderboard')
if lb is None:
lb = leader_board.Leaderboard([])
return lb
def save_leaderboard(lb):
save('data/leaderboard', lb)
def load_game(game_id):
return load('data/game_' + game_id)
# This function saves our hero as he/she exists right now.
def save_game(game_id, game_object):
save('data/game_' + game_id, game_object)
# This function will be called when our hero is killed. That means you can't play him/her again after death!
def delete_game(game_id):
delete('data/game_' + game_id)
# This function saves our hero as he/she exists right now.
def save(name, my_object):
# Open the file
with open(name + '.pkl', 'wb') as save_file:
# dump our_hero structure into the pickle file
pickle.dump(my_object, save_file)
# This helper function is to save an object to a "pickle" file, python's standard way to save objects to a file.
def load(name):
try:
# Open a File
with open(name + '.pkl', 'rb') as load_file:
# Load object from the file
my_object = pickle.load(load_file)
# After the object is read from file, return it
return my_object
except IOError:
print("Can't find file: " + name)
return None
# This function will be called when the hero is killed. That means you can't play him/her again after death!
def delete(name):
try:
os.remove(name + '.pkl')
except OSError as error:
print("Unable to Delete File: " + name)
pass # Don't stop the game if we can't delete the file.
| 27.764706 | 112 | 0.654131 | 296 | 1,888 | 4.074324 | 0.331081 | 0.039801 | 0.049751 | 0.034826 | 0.323383 | 0.258706 | 0.212272 | 0.212272 | 0.212272 | 0.212272 | 0 | 0 | 0.258475 | 1,888 | 67 | 113 | 28.179104 | 0.861429 | 0.389301 | 0 | 0.184211 | 0 | 0 | 0.109649 | 0 | 0 | 0 | 0 | 0.014925 | 0 | 1 | 0.236842 | false | 0.052632 | 0.078947 | 0.026316 | 0.421053 | 0.052632 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 3 |
c2820da320022a1cdc91123ac9a17bfbe37234dc | 80 | py | Python | app_src/__init__.py | Reinski/netdevices_manager | fa4c563313ef6bc9969e4878cf79998e23be0ec6 | [
"MIT"
] | null | null | null | app_src/__init__.py | Reinski/netdevices_manager | fa4c563313ef6bc9969e4878cf79998e23be0ec6 | [
"MIT"
] | null | null | null | app_src/__init__.py | Reinski/netdevices_manager | fa4c563313ef6bc9969e4878cf79998e23be0ec6 | [
"MIT"
] | null | null | null | import flask
app = flask.Flask(__name__)
app.secret_key = 'P35ANBRM055GufuWuukR' | 26.666667 | 39 | 0.8125 | 10 | 80 | 6 | 0.7 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.068493 | 0.0875 | 80 | 3 | 39 | 26.666667 | 0.753425 | 0 | 0 | 0 | 0 | 0 | 0.246914 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.333333 | 0 | 0.333333 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
c29a591f0012091d0dab901c5a00effe6ba44fdb | 376 | py | Python | ecommerce/blog/admin.py | mhdirajabi/django-drf-e-commerce | 526044a728f9f073a21386ff7f67ac570f4755c6 | [
"MIT"
] | null | null | null | ecommerce/blog/admin.py | mhdirajabi/django-drf-e-commerce | 526044a728f9f073a21386ff7f67ac570f4755c6 | [
"MIT"
] | null | null | null | ecommerce/blog/admin.py | mhdirajabi/django-drf-e-commerce | 526044a728f9f073a21386ff7f67ac570f4755c6 | [
"MIT"
] | null | null | null | from django.contrib import admin
from .models import Category, Post, Tag
# Register your models here.
class PostAdmin(admin.ModelAdmin):
list_display = ("title", "content", "slug")
class CategoryAdmin(admin.ModelAdmin):
list_display = ("name", "owner")
admin.site.register(Post, PostAdmin)
admin.site.register(Category, CategoryAdmin)
admin.site.register(Tag)
| 19.789474 | 47 | 0.744681 | 46 | 376 | 6.043478 | 0.521739 | 0.097122 | 0.183453 | 0.18705 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.130319 | 376 | 18 | 48 | 20.888889 | 0.850153 | 0.069149 | 0 | 0 | 0 | 0 | 0.071839 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.222222 | 0 | 0.666667 | 0 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
c2a5d4c2eea01132dddf0dcf07f33408b24acd26 | 2,695 | py | Python | dcsh/merge.py | eanderton/dash | 3e35a7a8288a3ba66a2947a5a61d7a4551fa1b91 | [
"MIT"
] | null | null | null | dcsh/merge.py | eanderton/dash | 3e35a7a8288a3ba66a2947a5a61d7a4551fa1b91 | [
"MIT"
] | null | null | null | dcsh/merge.py | eanderton/dash | 3e35a7a8288a3ba66a2947a5a61d7a4551fa1b91 | [
"MIT"
] | null | null | null | """Utility for configurable dictionary merges."""
class NoValue(object):
""" Placeholder for a no-value type. """
pass
# singleton for NoValue
no_value = NoValue()
def discard(dst, src, key, default):
"""Does nothing, effectively discarding the merged value."""
return no_value
def override(left, right, key, default):
"""Returns right[key] if exists, else left[key]."""
return right.get(key, left.get(key, default))
def shallow(left, right, key, default):
"""Updates fields from src at key, into key at dst. """
left_v = left.get(key, default)
if key in right:
right_v = right[key]
if key in left:
if isinstance(left_v, dict) and isinstance(right_v, dict):
return dict(left_v, **right_v)
return right_v
return left_v
# TODO: deep merge
class Merge(object):
def __init__(self, key_fn, default_fn, *args, **kwargs):
"""Creates a merge strategy for the provided dictionaries and/or keys."""
self._key_fn = key_fn
if isinstance(key_fn, list):
self._key_fn = lambda l, r: key_fn
self._default_fn = default_fn
self._strategy = dict(*args, **kwargs)
def __call__(self, left, right, default=None):
"""Returns the merge of right to left for all keys in keys.
If no such key exists in left or right, default is used as the value.
"""
keys = self._key_fn(left, right)
result = {}
for key in keys:
value = self._strategy.get(key, self._default_fn)(left, right, key, default)
if value != no_value:
result[key] = value
return result
def inner(left, right):
"""Returns keys from right to left for all keys that exist in both."""
return set(left.keys()) & set(right.keys())
def full(left, right):
"""Returns keys from right to left for all keys that exist in either."""
return set(left.keys()) | set(right.keys())
def outermost(left, right):
"""Returns keys from right to left for all keys exclusive to both left and right."""
return set(left.keys()) ^ set(right.keys())
def left(left, right):
"""Returns keys from right to left for all keys in left."""
return set(left.keys())
def leftmost(left, right):
"""Returns keys from right to left for keys that exist only in left."""
return set(left.keys()) - set(right.keys())
def right(left, right):
"""Returns keys from right to left for all keys in right."""
return set(right.keys())
def rightmost(left, right):
"""Returns keys from right to left for keys that exist only in right."""
return set(right.keys()) - set(left.keys())
| 28.670213 | 88 | 0.632653 | 395 | 2,695 | 4.222785 | 0.220253 | 0.064748 | 0.052758 | 0.067146 | 0.351918 | 0.351918 | 0.309353 | 0.295564 | 0.218825 | 0.218825 | 0 | 0 | 0.246382 | 2,695 | 93 | 89 | 28.978495 | 0.82127 | 0.34026 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.010753 | 0 | 1 | 0.266667 | false | 0.022222 | 0 | 0 | 0.6 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
c2a851298af9088a1e5056007dd82a73c517b0ef | 165 | py | Python | poc_dependabot/__init__.py | xmnlab/poc-dependabot | ab8935bfe1d16c0b684f20b7e30bbe49470030af | [
"MIT"
] | null | null | null | poc_dependabot/__init__.py | xmnlab/poc-dependabot | ab8935bfe1d16c0b684f20b7e30bbe49470030af | [
"MIT"
] | 9 | 2022-02-01T20:43:25.000Z | 2022-02-11T22:28:21.000Z | poc_dependabot/__init__.py | xmnlab/poc-dependabot | ab8935bfe1d16c0b684f20b7e30bbe49470030af | [
"MIT"
] | null | null | null | # -*- coding: utf-8 -*-
"""Top-level package for PoC DependaBot."""
__author__ = """Ivan Ogasawara"""
__email__ = 'ivan.ogasawara@gmail.com'
__version__ = '1.0.0'
| 20.625 | 43 | 0.654545 | 21 | 165 | 4.571429 | 0.857143 | 0.270833 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.027972 | 0.133333 | 165 | 7 | 44 | 23.571429 | 0.643357 | 0.363636 | 0 | 0 | 0 | 0 | 0.434343 | 0.242424 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
c2b0ce4da307cb766626d54e38bf998dca06e3b7 | 159 | py | Python | Python_Basic_Programs/03_Data_Types.py | abhayanigam/Learn_Python_Programming | 801e3fff2b1fe35e4c93f4ced649516c519eb8f9 | [
"MIT"
] | 1 | 2021-08-28T15:10:26.000Z | 2021-08-28T15:10:26.000Z | Python_Basic_Programs/03_Data_Types.py | abhayanigam/Learn_Python_Programming | 801e3fff2b1fe35e4c93f4ced649516c519eb8f9 | [
"MIT"
] | null | null | null | Python_Basic_Programs/03_Data_Types.py | abhayanigam/Learn_Python_Programming | 801e3fff2b1fe35e4c93f4ced649516c519eb8f9 | [
"MIT"
] | null | null | null | # Data Types
a = 5
print(a, "is of type", type(a))
a = 2.0
print(a, "is of type", type(a))
a = 1+2j
print(a, "is complex number?", isinstance(1+2j,complex)) | 15.9 | 56 | 0.610063 | 33 | 159 | 2.939394 | 0.454545 | 0.185567 | 0.247423 | 0.206186 | 0.412371 | 0.412371 | 0.412371 | 0.412371 | 0 | 0 | 0 | 0.053846 | 0.18239 | 159 | 10 | 56 | 15.9 | 0.692308 | 0.062893 | 0 | 0.333333 | 0 | 0 | 0.256757 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0.5 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 3 |
c2c9c13177f4b25d82b251702e09592343de443f | 2,229 | py | Python | blogs/models.py | AgnosticMe/phleeb | 48f85048d2db5d16d243feee2f84a961682a0f4d | [
"MIT"
] | null | null | null | blogs/models.py | AgnosticMe/phleeb | 48f85048d2db5d16d243feee2f84a961682a0f4d | [
"MIT"
] | null | null | null | blogs/models.py | AgnosticMe/phleeb | 48f85048d2db5d16d243feee2f84a961682a0f4d | [
"MIT"
] | null | null | null | from django.db import models
from django.conf import settings
from django.utils.text import slugify
import uuid
# Create your models here.
class Category(models.Model):
title = models.CharField(max_length=50)
slug = models.SlugField(editable=False)
def save(self, *args, **kwargs):
self.slug = f'{slugify(self.title)}--{uuid.uuid4()}'
super(Category, self).save(*args, **kwargs)
def __str__(self):
return self.title
def blog_count(self):
return self.blogs.all().count()
class Tag(models.Model):
title = models.CharField(max_length=50)
slug = models.SlugField(editable=False)
def save(self, *args, **kwargs):
self.slug = slugify(self.title)
super(Tag, self).save(*args, **kwargs)
def __str__(self):
return self.title
def blog_count(self):
return self.blogs.all().count()
class Blog(models.Model):
title = models.CharField(max_length=150)
content = models.TextField()
publishing_date = models.DateTimeField(auto_now_add=True)
image = models.ImageField(upload_to='uploads/')
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
slug = models.SlugField(editable=False)
category = models.ForeignKey(Category, on_delete=models.CASCADE, blank=True, related_name='blogs')
tag = models.ManyToManyField(Tag, related_name='blogs', blank=True)
slider_blog = models.BooleanField(default=False)
hit = models.PositiveIntegerField(default=0)
def comment_count(self):
return self.comments.all().count()
def save(self, *args, **kwargs):
self.slug = f'{slugify(self.title)}--{uuid.uuid4()}'
super(Blog, self).save(*args, **kwargs)
def __str__(self):
return self.title
def blog_tags(self):
return ', '.join(str(tag) for tag in self.tag.all())
class Comment(models.Model):
blog = models.ForeignKey(Blog, on_delete=models.CASCADE, related_name='comments')
name = models.CharField(max_length=100)
email = models.EmailField(max_length=150)
content = models.TextField()
publishing_date = models.DateTimeField(auto_now_add=True)
def __str__(self):
return self.blog.title
| 28.21519 | 102 | 0.680574 | 286 | 2,229 | 5.160839 | 0.283217 | 0.054201 | 0.066396 | 0.065041 | 0.51897 | 0.48374 | 0.48374 | 0.462737 | 0.462737 | 0.462737 | 0 | 0.00884 | 0.187977 | 2,229 | 78 | 103 | 28.576923 | 0.80663 | 0.010767 | 0 | 0.480769 | 0 | 0 | 0.046364 | 0.033636 | 0 | 0 | 0 | 0 | 0 | 1 | 0.211538 | false | 0 | 0.076923 | 0.153846 | 0.884615 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
c2d24a631ce975d662b9f0385bf8ca113bd3d156 | 262 | py | Python | doc/movies/extract_snippets/Reader.py | palmskog/hydra-battles | 8ad2a5397c748cac56c676e5a0745a5935ceec46 | [
"MIT"
] | 40 | 2020-10-20T13:51:22.000Z | 2022-03-09T10:22:16.000Z | doc/movies/extract_snippets/Reader.py | palmskog/hydra-battles | 8ad2a5397c748cac56c676e5a0745a5935ceec46 | [
"MIT"
] | 78 | 2020-10-20T16:48:09.000Z | 2022-03-26T17:49:00.000Z | doc/movies/extract_snippets/Reader.py | palmskog/hydra-battles | 8ad2a5397c748cac56c676e5a0745a5935ceec46 | [
"MIT"
] | 7 | 2020-10-20T12:06:08.000Z | 2021-08-30T16:10:35.000Z | from typing import Tuple
from abc import abstractmethod
class Reader:
"""
Read line by line
"""
@abstractmethod
def __iter__(self) -> Tuple[int, str]:
"""
return tuple with line number and line
:yield:
"""
pass
| 15.411765 | 42 | 0.587786 | 30 | 262 | 5 | 0.733333 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.320611 | 262 | 16 | 43 | 16.375 | 0.842697 | 0.244275 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.166667 | false | 0.166667 | 0.333333 | 0 | 0.666667 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 1 | 0 | 0 | 3 |
6c2f9014d55f0b3df42112ac18cc1cf5d75d6da7 | 442 | py | Python | Inheritance/mix_it_new/project/parking_mall/parking_mall.py | MNikov/Python-OOP-October-2020 | a53e4555758ec810605e31e7b2c71b65c49b2332 | [
"MIT"
] | null | null | null | Inheritance/mix_it_new/project/parking_mall/parking_mall.py | MNikov/Python-OOP-October-2020 | a53e4555758ec810605e31e7b2c71b65c49b2332 | [
"MIT"
] | null | null | null | Inheritance/mix_it_new/project/parking_mall/parking_mall.py | MNikov/Python-OOP-October-2020 | a53e4555758ec810605e31e7b2c71b65c49b2332 | [
"MIT"
] | null | null | null | from project.capacity_mixin import CapacityMixin
class ParkingMall(CapacityMixin):
def __init__(self, parking_lots):
self.parking_lots = parking_lots
def check_availability(self):
fn_value = self.get_capacity(self.parking_lots, 1)
if isinstance(fn_value, str):
return "There are no more parking lots!"
self.parking_lots -= 1
return f"Parking lots available: {self.parking_lots}"
| 31.571429 | 61 | 0.696833 | 56 | 442 | 5.232143 | 0.517857 | 0.300341 | 0.255973 | 0.150171 | 0.177474 | 0 | 0 | 0 | 0 | 0 | 0 | 0.005831 | 0.223982 | 442 | 13 | 62 | 34 | 0.848397 | 0 | 0 | 0 | 0 | 0 | 0.167421 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.2 | false | 0 | 0.1 | 0 | 0.6 | 0 | 0 | 0 | 0 | null | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 |
6c489591ca076dc4e68d56363aa97009538ae687 | 776 | py | Python | proxy/indexer/pg_common.py | nghiatomo/proxy-model.py | a52737d3418bbceaf9dd64c3a985b00f526a8ea3 | [
"BSD-3-Clause"
] | 4 | 2021-09-10T21:29:27.000Z | 2021-11-17T01:43:58.000Z | proxy/indexer/pg_common.py | nghiatomo/proxy-model.py | a52737d3418bbceaf9dd64c3a985b00f526a8ea3 | [
"BSD-3-Clause"
] | 339 | 2021-04-28T06:38:54.000Z | 2022-03-31T11:16:36.000Z | proxy/indexer/pg_common.py | nghiatomo/proxy-model.py | a52737d3418bbceaf9dd64c3a985b00f526a8ea3 | [
"BSD-3-Clause"
] | 5 | 2021-08-17T14:30:28.000Z | 2022-01-18T07:19:47.000Z | import psycopg2
import os
POSTGRES_DB = os.environ.get("POSTGRES_DB", "neon-db")
POSTGRES_USER = os.environ.get("POSTGRES_USER", "neon-proxy")
POSTGRES_PASSWORD = os.environ.get("POSTGRES_PASSWORD", "neon-proxy-pass")
POSTGRES_HOST = os.environ.get("POSTGRES_HOST", "localhost")
try:
from cPickle import dumps, loads, HIGHEST_PROTOCOL as PICKLE_PROTOCOL
except ImportError:
from pickle import dumps, loads, HIGHEST_PROTOCOL as PICKLE_PROTOCOL
def encode(obj):
"""Serialize an object using pickle to a binary format accepted by SQLite."""
return psycopg2.Binary(dumps(obj, protocol=PICKLE_PROTOCOL))
def decode(obj):
"""Deserialize objects retrieved from SQLite."""
return loads(bytes(obj))
def dummy(obj):
"""Does nothing"""
return obj
| 27.714286 | 81 | 0.740979 | 105 | 776 | 5.352381 | 0.457143 | 0.064057 | 0.085409 | 0.142349 | 0.16726 | 0.16726 | 0.16726 | 0.16726 | 0 | 0 | 0 | 0.003008 | 0.143041 | 776 | 27 | 82 | 28.740741 | 0.842105 | 0.16366 | 0 | 0 | 0 | 0 | 0.150079 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.1875 | false | 0.0625 | 0.3125 | 0 | 0.6875 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 1 | 0 | 0 | 3 |
6c6ae757333709f1d6baa9ea7433cc347a9bba71 | 209,545 | py | Python | reefbot_hudui/bin/vlc.py | MRSD2018/reefbot-1 | a595ca718d0cda277726894a3105815cef000475 | [
"MIT"
] | null | null | null | reefbot_hudui/bin/vlc.py | MRSD2018/reefbot-1 | a595ca718d0cda277726894a3105815cef000475 | [
"MIT"
] | null | null | null | reefbot_hudui/bin/vlc.py | MRSD2018/reefbot-1 | a595ca718d0cda277726894a3105815cef000475 | [
"MIT"
] | null | null | null | #! /usr/bin/python
#
# Python ctypes bindings for VLC
# Copyright (C) 2009 the VideoLAN team
# $Id: $
#
# Authors: Olivier Aubert <olivier.aubert at liris.cnrs.fr>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
#
"""This module provides bindings for the
U{libvlc<http://wiki.videolan.org/ExternalAPI>}.
You can find documentation at U{http://www.advene.org/download/python-ctypes/}.
Basically, the most important class is L{Instance}, which is used to
create a libvlc Instance. From this instance, you can then create
L{MediaPlayer} and L{MediaListPlayer} instances.
"""
import logging
import ctypes
import sys
build_date="Mon Sep 20 15:42:06 2010"
# Used for win32 and MacOS X
detected_plugin_path=None
if sys.platform == 'linux2':
try:
dll=ctypes.CDLL('libvlc.so')
except OSError:
dll=ctypes.CDLL('libvlc.so.5')
elif sys.platform == 'win32':
import ctypes.util
import os
detected_plugin_path=None
path=ctypes.util.find_library('libvlc.dll')
if path is None:
# Try to use registry settings
import _winreg
detected_plugin_path_found = None
subkey, name = 'Software\\VideoLAN\\VLC','InstallDir'
for hkey in _winreg.HKEY_LOCAL_MACHINE, _winreg.HKEY_CURRENT_USER:
try:
reg = _winreg.OpenKey(hkey, subkey)
detected_plugin_path_found, type_id = _winreg.QueryValueEx(reg, name)
_winreg.CloseKey(reg)
break
except _winreg.error:
pass
if detected_plugin_path_found:
detected_plugin_path = detected_plugin_path_found
else:
# Try a standard location.
p='c:\\Program Files\\VideoLAN\\VLC\\libvlc.dll'
if os.path.exists(p):
detected_plugin_path=os.path.dirname(p)
os.chdir(detected_plugin_path)
# If chdir failed, this will not work and raise an exception
path='libvlc.dll'
else:
detected_plugin_path=os.path.dirname(path)
dll=ctypes.CDLL(path)
elif sys.platform == 'darwin':
# FIXME: should find a means to configure path
d='/Applications/VLC.app'
import os
if os.path.exists(d):
dll=ctypes.CDLL(d+'/Contents/MacOS/lib/libvlc.dylib')
detected_plugin_path=d+'/Contents/MacOS/modules'
else:
# Hope some default path is set...
dll=ctypes.CDLL('libvlc.dylib')
#
# Generated enum types.
#
class EventType(ctypes.c_ulong):
"""*
Event types
"""
_names={
0: 'MediaMetaChanged',
1: 'MediaSubItemAdded',
2: 'MediaDurationChanged',
3: 'MediaParsedChanged',
4: 'MediaFreed',
5: 'MediaStateChanged',
0x100: 'MediaPlayerMediaChanged',
257: 'MediaPlayerNothingSpecial',
258: 'MediaPlayerOpening',
259: 'MediaPlayerBuffering',
260: 'MediaPlayerPlaying',
261: 'MediaPlayerPaused',
262: 'MediaPlayerStopped',
263: 'MediaPlayerForward',
264: 'MediaPlayerBackward',
265: 'MediaPlayerEndReached',
266: 'MediaPlayerEncounteredError',
267: 'MediaPlayerTimeChanged',
268: 'MediaPlayerPositionChanged',
269: 'MediaPlayerSeekableChanged',
270: 'MediaPlayerPausableChanged',
271: 'MediaPlayerTitleChanged',
272: 'MediaPlayerSnapshotTaken',
273: 'MediaPlayerLengthChanged',
0x200: 'MediaListItemAdded',
513: 'MediaListWillAddItem',
514: 'MediaListItemDeleted',
515: 'MediaListWillDeleteItem',
0x300: 'MediaListViewItemAdded',
769: 'MediaListViewWillAddItem',
770: 'MediaListViewItemDeleted',
771: 'MediaListViewWillDeleteItem',
0x400: 'MediaListPlayerPlayed',
1025: 'MediaListPlayerNextItemSet',
1026: 'MediaListPlayerStopped',
0x500: 'MediaDiscovererStarted',
1281: 'MediaDiscovererEnded',
0x600: 'VlmMediaAdded',
1537: 'VlmMediaRemoved',
1538: 'VlmMediaChanged',
1539: 'VlmMediaInstanceStarted',
1540: 'VlmMediaInstanceStopped',
1541: 'VlmMediaInstanceStatusInit',
1542: 'VlmMediaInstanceStatusOpening',
1543: 'VlmMediaInstanceStatusPlaying',
1544: 'VlmMediaInstanceStatusPause',
1545: 'VlmMediaInstanceStatusEnd',
1546: 'VlmMediaInstanceStatusError',
}
def __repr__(self):
return ".".join((self.__class__.__module__, self.__class__.__name__, self._names[self.value]))
def __eq__(self, other):
return ( (isinstance(other, ctypes.c_ulong) and self.value == other.value)
or (isinstance(other, (int, long)) and self.value == other ) )
def __ne__(self, other):
return not self.__eq__(other)
EventType.MediaMetaChanged=EventType(0)
EventType.MediaSubItemAdded=EventType(1)
EventType.MediaDurationChanged=EventType(2)
EventType.MediaParsedChanged=EventType(3)
EventType.MediaFreed=EventType(4)
EventType.MediaStateChanged=EventType(5)
EventType.MediaPlayerMediaChanged=EventType(0x100)
EventType.MediaPlayerNothingSpecial=EventType(257)
EventType.MediaPlayerOpening=EventType(258)
EventType.MediaPlayerBuffering=EventType(259)
EventType.MediaPlayerPlaying=EventType(260)
EventType.MediaPlayerPaused=EventType(261)
EventType.MediaPlayerStopped=EventType(262)
EventType.MediaPlayerForward=EventType(263)
EventType.MediaPlayerBackward=EventType(264)
EventType.MediaPlayerEndReached=EventType(265)
EventType.MediaPlayerEncounteredError=EventType(266)
EventType.MediaPlayerTimeChanged=EventType(267)
EventType.MediaPlayerPositionChanged=EventType(268)
EventType.MediaPlayerSeekableChanged=EventType(269)
EventType.MediaPlayerPausableChanged=EventType(270)
EventType.MediaPlayerTitleChanged=EventType(271)
EventType.MediaPlayerSnapshotTaken=EventType(272)
EventType.MediaPlayerLengthChanged=EventType(273)
EventType.MediaListItemAdded=EventType(0x200)
EventType.MediaListWillAddItem=EventType(513)
EventType.MediaListItemDeleted=EventType(514)
EventType.MediaListWillDeleteItem=EventType(515)
EventType.MediaListViewItemAdded=EventType(0x300)
EventType.MediaListViewWillAddItem=EventType(769)
EventType.MediaListViewItemDeleted=EventType(770)
EventType.MediaListViewWillDeleteItem=EventType(771)
EventType.MediaListPlayerPlayed=EventType(0x400)
EventType.MediaListPlayerNextItemSet=EventType(1025)
EventType.MediaListPlayerStopped=EventType(1026)
EventType.MediaDiscovererStarted=EventType(0x500)
EventType.MediaDiscovererEnded=EventType(1281)
EventType.VlmMediaAdded=EventType(0x600)
EventType.VlmMediaRemoved=EventType(1537)
EventType.VlmMediaChanged=EventType(1538)
EventType.VlmMediaInstanceStarted=EventType(1539)
EventType.VlmMediaInstanceStopped=EventType(1540)
EventType.VlmMediaInstanceStatusInit=EventType(1541)
EventType.VlmMediaInstanceStatusOpening=EventType(1542)
EventType.VlmMediaInstanceStatusPlaying=EventType(1543)
EventType.VlmMediaInstanceStatusPause=EventType(1544)
EventType.VlmMediaInstanceStatusEnd=EventType(1545)
EventType.VlmMediaInstanceStatusError=EventType(1546)
class Meta(ctypes.c_ulong):
"""* Meta data types */
"""
_names={
0: 'Title',
1: 'Artist',
2: 'Genre',
3: 'Copyright',
4: 'Album',
5: 'TrackNumber',
6: 'Description',
7: 'Rating',
8: 'Date',
9: 'Setting',
10: 'URL',
11: 'Language',
12: 'NowPlaying',
13: 'Publisher',
14: 'EncodedBy',
15: 'ArtworkURL',
16: 'TrackID',
}
def __repr__(self):
return ".".join((self.__class__.__module__, self.__class__.__name__, self._names[self.value]))
def __eq__(self, other):
return ( (isinstance(other, ctypes.c_ulong) and self.value == other.value)
or (isinstance(other, (int, long)) and self.value == other ) )
def __ne__(self, other):
return not self.__eq__(other)
Meta.Title=Meta(0)
Meta.Artist=Meta(1)
Meta.Genre=Meta(2)
Meta.Copyright=Meta(3)
Meta.Album=Meta(4)
Meta.TrackNumber=Meta(5)
Meta.Description=Meta(6)
Meta.Rating=Meta(7)
Meta.Date=Meta(8)
Meta.Setting=Meta(9)
Meta.URL=Meta(10)
Meta.Language=Meta(11)
Meta.NowPlaying=Meta(12)
Meta.Publisher=Meta(13)
Meta.EncodedBy=Meta(14)
Meta.ArtworkURL=Meta(15)
Meta.TrackID=Meta(16)
class State(ctypes.c_ulong):
"""*
Note the order of libvlc_state_t enum must match exactly the order of
\see mediacontrol_PlayerStatus, \see input_state_e enums,
and VideoLAN.LibVLC.State (at bindings/cil/src/media.cs).
Expected states by web plugins are:
IDLE/CLOSE=0, OPENING=1, BUFFERING=2, PLAYING=3, PAUSED=4,
STOPPING=5, ENDED=6, ERROR=7
"""
_names={
0: 'NothingSpecial',
1: 'Opening',
2: 'Buffering',
3: 'Playing',
4: 'Paused',
5: 'Stopped',
6: 'Ended',
7: 'Error',
}
def __repr__(self):
return ".".join((self.__class__.__module__, self.__class__.__name__, self._names[self.value]))
def __eq__(self, other):
return ( (isinstance(other, ctypes.c_ulong) and self.value == other.value)
or (isinstance(other, (int, long)) and self.value == other ) )
def __ne__(self, other):
return not self.__eq__(other)
State.NothingSpecial=State(0)
State.Opening=State(1)
State.Buffering=State(2)
State.Playing=State(3)
State.Paused=State(4)
State.Stopped=State(5)
State.Ended=State(6)
State.Error=State(7)
class TrackType(ctypes.c_ulong):
"""
"""
_names={
-1: 'unknown',
0: 'audio',
1: 'video',
2: 'text',
}
def __repr__(self):
return ".".join((self.__class__.__module__, self.__class__.__name__, self._names[self.value]))
def __eq__(self, other):
return ( (isinstance(other, ctypes.c_ulong) and self.value == other.value)
or (isinstance(other, (int, long)) and self.value == other ) )
def __ne__(self, other):
return not self.__eq__(other)
TrackType.unknown=TrackType(-1)
TrackType.audio=TrackType(0)
TrackType.video=TrackType(1)
TrackType.text=TrackType(2)
class PlaybackMode(ctypes.c_ulong):
"""*
Defines playback modes for playlist.
"""
_names={
0: 'default',
1: 'loop',
2: 'repeat',
}
def __repr__(self):
return ".".join((self.__class__.__module__, self.__class__.__name__, self._names[self.value]))
def __eq__(self, other):
return ( (isinstance(other, ctypes.c_ulong) and self.value == other.value)
or (isinstance(other, (int, long)) and self.value == other ) )
def __ne__(self, other):
return not self.__eq__(other)
PlaybackMode.default=PlaybackMode(0)
PlaybackMode.loop=PlaybackMode(1)
PlaybackMode.repeat=PlaybackMode(2)
class VideoMarqueeOption(ctypes.c_ulong):
"""*
Marq options definition
"""
_names={
0: 'Enable',
1: 'Text',
2: 'Color',
3: 'Opacity',
4: 'Position',
5: 'Refresh',
6: 'Size',
7: 'Timeout',
8: 'marquee_X',
9: 'marquee_Y',
}
def __repr__(self):
return ".".join((self.__class__.__module__, self.__class__.__name__, self._names[self.value]))
def __eq__(self, other):
return ( (isinstance(other, ctypes.c_ulong) and self.value == other.value)
or (isinstance(other, (int, long)) and self.value == other ) )
def __ne__(self, other):
return not self.__eq__(other)
VideoMarqueeOption.Enable=VideoMarqueeOption(0)
VideoMarqueeOption.Text=VideoMarqueeOption(1)
VideoMarqueeOption.Color=VideoMarqueeOption(2)
VideoMarqueeOption.Opacity=VideoMarqueeOption(3)
VideoMarqueeOption.Position=VideoMarqueeOption(4)
VideoMarqueeOption.Refresh=VideoMarqueeOption(5)
VideoMarqueeOption.Size=VideoMarqueeOption(6)
VideoMarqueeOption.Timeout=VideoMarqueeOption(7)
VideoMarqueeOption.marquee_X=VideoMarqueeOption(8)
VideoMarqueeOption.marquee_Y=VideoMarqueeOption(9)
class VideoLogoOption(ctypes.c_ulong):
"""* option values for libvlc_video_{get,set}_logo_{int,string} */
"""
_names={
0: 'enable',
1: 'file',
2: 'logo_x',
3: 'logo_y',
4: 'delay',
5: 'repeat',
6: 'opacity',
7: 'position',
}
def __repr__(self):
return ".".join((self.__class__.__module__, self.__class__.__name__, self._names[self.value]))
def __eq__(self, other):
return ( (isinstance(other, ctypes.c_ulong) and self.value == other.value)
or (isinstance(other, (int, long)) and self.value == other ) )
def __ne__(self, other):
return not self.__eq__(other)
VideoLogoOption.enable=VideoLogoOption(0)
VideoLogoOption.file=VideoLogoOption(1)
VideoLogoOption.logo_x=VideoLogoOption(2)
VideoLogoOption.logo_y=VideoLogoOption(3)
VideoLogoOption.delay=VideoLogoOption(4)
VideoLogoOption.repeat=VideoLogoOption(5)
VideoLogoOption.opacity=VideoLogoOption(6)
VideoLogoOption.position=VideoLogoOption(7)
class VideoAdjustOption(ctypes.c_ulong):
"""* option values for libvlc_video_{get,set}_adjust_{int,float,bool} */
"""
_names={
0: 'Enable',
1: 'Contrast',
2: 'Brightness',
3: 'Hue',
4: 'Saturation',
5: 'Gamma',
}
def __repr__(self):
return ".".join((self.__class__.__module__, self.__class__.__name__, self._names[self.value]))
def __eq__(self, other):
return ( (isinstance(other, ctypes.c_ulong) and self.value == other.value)
or (isinstance(other, (int, long)) and self.value == other ) )
def __ne__(self, other):
return not self.__eq__(other)
VideoAdjustOption.Enable=VideoAdjustOption(0)
VideoAdjustOption.Contrast=VideoAdjustOption(1)
VideoAdjustOption.Brightness=VideoAdjustOption(2)
VideoAdjustOption.Hue=VideoAdjustOption(3)
VideoAdjustOption.Saturation=VideoAdjustOption(4)
VideoAdjustOption.Gamma=VideoAdjustOption(5)
class AudioOutputDeviceTypes(ctypes.c_ulong):
"""*
Audio device types
"""
_names={
-1: 'Error',
1: 'Mono',
2: 'Stereo',
4: '_2F2R',
5: '_3F2R',
6: '_5_1',
7: '_6_1',
8: '_7_1',
10: 'SPDIF',
}
def __repr__(self):
return ".".join((self.__class__.__module__, self.__class__.__name__, self._names[self.value]))
def __eq__(self, other):
return ( (isinstance(other, ctypes.c_ulong) and self.value == other.value)
or (isinstance(other, (int, long)) and self.value == other ) )
def __ne__(self, other):
return not self.__eq__(other)
AudioOutputDeviceTypes.Error=AudioOutputDeviceTypes(-1)
AudioOutputDeviceTypes.Mono=AudioOutputDeviceTypes(1)
AudioOutputDeviceTypes.Stereo=AudioOutputDeviceTypes(2)
AudioOutputDeviceTypes._2F2R=AudioOutputDeviceTypes(4)
AudioOutputDeviceTypes._3F2R=AudioOutputDeviceTypes(5)
AudioOutputDeviceTypes._5_1=AudioOutputDeviceTypes(6)
AudioOutputDeviceTypes._6_1=AudioOutputDeviceTypes(7)
AudioOutputDeviceTypes._7_1=AudioOutputDeviceTypes(8)
AudioOutputDeviceTypes.SPDIF=AudioOutputDeviceTypes(10)
class AudioOutputChannel(ctypes.c_ulong):
"""*
Audio channels
"""
_names={
-1: 'Error',
1: 'Stereo',
2: 'RStereo',
3: 'Left',
4: 'Right',
5: 'Dolbys',
}
def __repr__(self):
return ".".join((self.__class__.__module__, self.__class__.__name__, self._names[self.value]))
def __eq__(self, other):
return ( (isinstance(other, ctypes.c_ulong) and self.value == other.value)
or (isinstance(other, (int, long)) and self.value == other ) )
def __ne__(self, other):
return not self.__eq__(other)
AudioOutputChannel.Error=AudioOutputChannel(-1)
AudioOutputChannel.Stereo=AudioOutputChannel(1)
AudioOutputChannel.RStereo=AudioOutputChannel(2)
AudioOutputChannel.Left=AudioOutputChannel(3)
AudioOutputChannel.Right=AudioOutputChannel(4)
AudioOutputChannel.Dolbys=AudioOutputChannel(5)
#
# End of generated enum types.
#
class ListPOINTER(object):
'''Just like a POINTER but accept a list of ctype as an argument.
'''
def __init__(self, etype):
self.etype = etype
def from_param(self, param):
if isinstance(param, (list, tuple)):
return (self.etype * len(param))(*param)
class LibVLCException(Exception):
"""Python exception raised by libvlc methods.
"""
pass
# From libvlc_structures.h
class MediaStats(ctypes.Structure):
_fields_= [
('read_bytes', ctypes.c_int ),
('input_bitrate', ctypes.c_float),
('demux_read_bytes', ctypes.c_int ),
('demux_bitrate', ctypes.c_float),
('demux_corrupted', ctypes.c_int ),
('demux_discontinuity', ctypes.c_int ),
('decoded_video', ctypes.c_int ),
('decoded_audio', ctypes.c_int ),
('displayed_pictures', ctypes.c_int ),
('lost_pictures', ctypes.c_int ),
('played_abuffers', ctypes.c_int ),
('lost_abuffers', ctypes.c_int ),
('sent_packets', ctypes.c_int ),
('sent_bytes', ctypes.c_int ),
('send_bitrate', ctypes.c_float),
]
def __str__(self):
return "MediaStats\n%s" % "\n".join( "%s:\t%s" % (n, getattr(self, n)) for n in self._fields_ )
class MediaTrackInfo(ctypes.Structure):
_fields_= [
('codec' , ctypes.c_uint32),
('id' , ctypes.c_int),
('type' , TrackType),
('profile' , ctypes.c_int),
('level' , ctypes.c_int),
('channels_or_height', ctypes.c_uint),
('rate_or_width' , ctypes.c_uint),
]
def __str__(self):
return "MediaTrackInfo \n%s" % "\n".join( "%s:\t%s" % (n, getattr(self, n)) for n in self._fields_ )
class PlaylistItem(ctypes.Structure):
_fields_= [
('id', ctypes.c_int),
('uri', ctypes.c_char_p),
('name', ctypes.c_char_p),
]
def __str__(self):
return "PlaylistItem #%d %s (%uri)" % (self.id, self.name, self.uri)
class LogMessage(ctypes.Structure):
_fields_= [
('size', ctypes.c_uint),
('severity', ctypes.c_int),
('type', ctypes.c_char_p),
('name', ctypes.c_char_p),
('header', ctypes.c_char_p),
('message', ctypes.c_char_p),
]
def __init__(self):
super(LogMessage, self).__init__()
self.size=ctypes.sizeof(self)
def __str__(self):
return "vlc.LogMessage(%d:%s): %s" % (self.severity, self.type, self.message)
class AudioOutput(ctypes.Structure):
def __str__(self):
return "vlc.AudioOutput(%s:%s)" % (self.name, self.description)
AudioOutput._fields_= [
('name', ctypes.c_char_p),
('description', ctypes.c_char_p),
('next', ctypes.POINTER(AudioOutput)),
]
class TrackDescription(ctypes.Structure):
def __str__(self):
return "vlc.TrackDescription(%d:%s)" % (self.id, self.name)
TrackDescription._fields_= [
('id', ctypes.c_int),
('name', ctypes.c_char_p),
('next', ctypes.POINTER(TrackDescription)),
]
def track_description_list(head):
"""Convert a TrackDescription linked list to a python list, and release the linked list.
"""
l = []
item = head
while item:
l.append( (item.contents.id, item.contents.name) )
item = item.contents.next
if head:
libvlc_track_description_release(head)
return l
### End of header.py ###
class EventManager(object):
def __new__(cls, pointer=None):
'''Internal method used for instanciating wrappers from ctypes.
'''
if pointer is None:
raise Exception("Internal method. Surely this class cannot be instanciated by itself.")
if pointer == 0:
return None
else:
o=object.__new__(cls)
o._as_parameter_=ctypes.c_void_p(pointer)
return o
@staticmethod
def from_param(arg):
'''(INTERNAL) ctypes parameter conversion method.
'''
return arg._as_parameter_
if hasattr(dll, 'libvlc_event_attach'):
def event_attach(self, i_event_type, f_callback, user_data):
"""Register for an event notification.
@param i_event_type: the desired event to which we want to listen
@param f_callback: the function to call when i_event_type occurs
@param user_data: user provided data to carry with the event
@return: 0 on success, ENOMEM on error
"""
return libvlc_event_attach(self, i_event_type, f_callback, user_data)
if hasattr(dll, 'libvlc_event_detach'):
def event_detach(self, i_event_type, f_callback, p_user_data):
"""Unregister an event notification.
@param i_event_type: the desired event to which we want to unregister
@param f_callback: the function to call when i_event_type occurs
@param p_user_data: user provided data to carry with the event
"""
return libvlc_event_detach(self, i_event_type, f_callback, p_user_data)
class Instance(object):
"""Create a new Instance instance.
It may take as parameter either:
- a string
- a list of strings as first parameters
- the parameters given as the constructor parameters (must be strings)
"""
@staticmethod
def from_param(arg):
'''(INTERNAL) ctypes parameter conversion method.
'''
return arg._as_parameter_
def __new__(cls, *p):
if p and p[0] == 0:
return None
elif p and isinstance(p[0], (int, long)):
# instance creation from ctypes
o=object.__new__(cls)
o._as_parameter_=ctypes.c_void_p(p[0])
return o
elif len(p) == 1 and isinstance(p[0], basestring):
# Only 1 string parameter: should be a parameter line
p=p[0].split(' ')
elif len(p) == 1 and isinstance(p[0], (tuple, list)):
p=p[0]
if not p and detected_plugin_path is not None:
# No parameters passed. Under win32 and MacOS, specify
# the detected_plugin_path if present.
p=[ 'vlc', '--plugin-path='+ detected_plugin_path ]
return libvlc_new(len(p), p)
def media_player_new(self, uri=None):
"""Create a new MediaPlayer instance.
@param uri: an optional URI to play in the player.
"""
p=libvlc_media_player_new(self)
if uri:
p.set_media(self.media_new(uri))
p._instance=self
return p
def media_list_player_new(self):
"""Create a new MediaListPlayer instance.
"""
p=libvlc_media_list_player_new(self)
p._instance=self
return p
def media_new(self, mrl, *options):
"""Create a new Media instance.
Options can be specified as supplementary string parameters, e.g.
m=i.media_new('foo.avi', 'sub-filter=marq{marquee=Hello}', 'vout-filter=invert')
"""
m=libvlc_media_new_location(self, mrl)
for o in options:
libvlc_media_add_option(m, o)
return m
def audio_output_enumerate_devices(self):
"""Enumerate the defined audio output devices.
The result is a list of dict (name, description)
"""
l = []
head = ao = libvlc_audio_output_list_get(self)
while ao:
l.append( { 'name': ao.contents.name,
'description': ao.contents.description,
'devices': [ { 'id': libvlc_audio_output_device_id(self, ao.contents.name, i),
'longname': libvlc_audio_output_device_longname(self, ao.contents.name, i) }
for i in range(libvlc_audio_output_device_count(self, ao.contents.name) ) ] } )
ao = ao.contents.next
libvlc_audio_output_list_release(head)
return l
if hasattr(dll, 'libvlc_release'):
def release(self):
"""Decrement the reference count of a libvlc instance, and destroy it
if it reaches zero.
"""
return libvlc_release(self)
if hasattr(dll, 'libvlc_retain'):
def retain(self):
"""Increments the reference count of a libvlc instance.
The initial reference count is 1 after libvlc_new() returns.
"""
return libvlc_retain(self)
if hasattr(dll, 'libvlc_add_intf'):
def add_intf(self, name):
"""Try to start a user interface for the libvlc instance.
@param name: interface name, or NULL for default
@return: 0 on success, -1 on error.
"""
return libvlc_add_intf(self, name)
if hasattr(dll, 'libvlc_wait'):
def wait(self):
"""Waits until an interface causes the instance to exit.
You should start at least one interface first, using libvlc_add_intf().
"""
return libvlc_wait(self)
if hasattr(dll, 'libvlc_set_user_agent'):
def set_user_agent(self, name, http):
"""Sets the application name. LibVLC passes this as the user agent string
when a protocol requires it.
@param name: human-readable application name, e.g. "FooBar player 1.2.3"
@param http: HTTP User Agent, e.g. "FooBar/1.2.3 Python/2.6.0"
"""
return libvlc_set_user_agent(self, name, http)
if hasattr(dll, 'libvlc_get_log_verbosity'):
def get_log_verbosity(self):
"""Return the VLC messaging verbosity level.
@return: verbosity level for messages
"""
return libvlc_get_log_verbosity(self)
if hasattr(dll, 'libvlc_set_log_verbosity'):
def set_log_verbosity(self, level):
"""Set the VLC messaging verbosity level.
@param level: log level
"""
return libvlc_set_log_verbosity(self, level)
if hasattr(dll, 'libvlc_log_open'):
def log_open(self):
"""Open a VLC message log instance.
@return: log message instance or NULL on error
"""
return libvlc_log_open(self)
if hasattr(dll, 'libvlc_media_new_location'):
def media_new_location(self, psz_mrl):
"""Create a media with a certain given media resource location.
See libvlc_media_release
@param psz_mrl: the MRL to read
@return: the newly created media or NULL on error
"""
return libvlc_media_new_location(self, psz_mrl)
if hasattr(dll, 'libvlc_media_new_path'):
def media_new_path(self, path):
"""Create a media with a certain file path.
See libvlc_media_release
@param path: local filesystem path
@return: the newly created media or NULL on error
"""
return libvlc_media_new_path(self, path)
if hasattr(dll, 'libvlc_media_new_as_node'):
def media_new_as_node(self, psz_name):
"""Create a media as an empty node with a given name.
See libvlc_media_release
@param psz_name: the name of the node
@return: the new empty media or NULL on error
"""
return libvlc_media_new_as_node(self, psz_name)
if hasattr(dll, 'libvlc_media_discoverer_new_from_name'):
def media_discoverer_new_from_name(self, psz_name):
"""Discover media service by name.
@param psz_name: service name
@return: media discover object or NULL in case of error
"""
return libvlc_media_discoverer_new_from_name(self, psz_name)
if hasattr(dll, 'libvlc_media_library_new'):
def media_library_new(self):
"""Create an new Media Library object
@return: a new object or NULL on error
"""
return libvlc_media_library_new(self)
if hasattr(dll, 'libvlc_media_list_new'):
def media_list_new(self):
"""Create an empty media list.
@return: empty media list, or NULL on error
"""
return libvlc_media_list_new(self)
if hasattr(dll, 'libvlc_audio_output_list_get'):
def audio_output_list_get(self):
"""Get the list of available audio outputs
@return: list of available audio outputs. It must be freed it with
"""
return libvlc_audio_output_list_get(self)
if hasattr(dll, 'libvlc_audio_output_device_count'):
def audio_output_device_count(self, psz_audio_output):
"""Get count of devices for audio output, these devices are hardware oriented
like analor or digital output of sound card
@param psz_audio_output: - name of audio output, See libvlc_audio_output_t
@return: number of devices
"""
return libvlc_audio_output_device_count(self, psz_audio_output)
if hasattr(dll, 'libvlc_audio_output_device_longname'):
def audio_output_device_longname(self, psz_audio_output, i_device):
"""Get long name of device, if not available short name given
@param psz_audio_output: - name of audio output, See libvlc_audio_output_t
@param i_device: device index
@return: long name of device
"""
return libvlc_audio_output_device_longname(self, psz_audio_output, i_device)
if hasattr(dll, 'libvlc_audio_output_device_id'):
def audio_output_device_id(self, psz_audio_output, i_device):
"""Get id name of device
@param psz_audio_output: - name of audio output, See libvlc_audio_output_t
@param i_device: device index
@return: id name of device, use for setting device, need to be free after use
"""
return libvlc_audio_output_device_id(self, psz_audio_output, i_device)
if hasattr(dll, 'libvlc_vlm_release'):
def vlm_release(self):
"""Release the vlm instance related to the given libvlc_instance_t
"""
return libvlc_vlm_release(self)
if hasattr(dll, 'libvlc_vlm_add_broadcast'):
def vlm_add_broadcast(self, psz_name, psz_input, psz_output, i_options, ppsz_options, b_enabled, b_loop):
"""Add a broadcast, with one input.
@param psz_name: the name of the new broadcast
@param psz_input: the input MRL
@param psz_output: the output MRL (the parameter to the "sout" variable)
@param i_options: number of additional options
@param ppsz_options: additional options
@param b_enabled: boolean for enabling the new broadcast
@param b_loop: Should this broadcast be played in loop ?
@return: 0 on success, -1 on error
"""
return libvlc_vlm_add_broadcast(self, psz_name, psz_input, psz_output, i_options, ppsz_options, b_enabled, b_loop)
if hasattr(dll, 'libvlc_vlm_add_vod'):
def vlm_add_vod(self, psz_name, psz_input, i_options, ppsz_options, b_enabled, psz_mux):
"""Add a vod, with one input.
@param psz_name: the name of the new vod media
@param psz_input: the input MRL
@param i_options: number of additional options
@param ppsz_options: additional options
@param b_enabled: boolean for enabling the new vod
@param psz_mux: the muxer of the vod media
@return: 0 on success, -1 on error
"""
return libvlc_vlm_add_vod(self, psz_name, psz_input, i_options, ppsz_options, b_enabled, psz_mux)
if hasattr(dll, 'libvlc_vlm_del_media'):
def vlm_del_media(self, psz_name):
"""Delete a media (VOD or broadcast).
@param psz_name: the media to delete
@return: 0 on success, -1 on error
"""
return libvlc_vlm_del_media(self, psz_name)
if hasattr(dll, 'libvlc_vlm_set_enabled'):
def vlm_set_enabled(self, psz_name, b_enabled):
"""Enable or disable a media (VOD or broadcast).
@param psz_name: the media to work on
@param b_enabled: the new status
@return: 0 on success, -1 on error
"""
return libvlc_vlm_set_enabled(self, psz_name, b_enabled)
if hasattr(dll, 'libvlc_vlm_set_output'):
def vlm_set_output(self, psz_name, psz_output):
"""Set the output for a media.
@param psz_name: the media to work on
@param psz_output: the output MRL (the parameter to the "sout" variable)
@return: 0 on success, -1 on error
"""
return libvlc_vlm_set_output(self, psz_name, psz_output)
if hasattr(dll, 'libvlc_vlm_set_input'):
def vlm_set_input(self, psz_name, psz_input):
"""Set a media's input MRL. This will delete all existing inputs and
add the specified one.
@param psz_name: the media to work on
@param psz_input: the input MRL
@return: 0 on success, -1 on error
"""
return libvlc_vlm_set_input(self, psz_name, psz_input)
if hasattr(dll, 'libvlc_vlm_add_input'):
def vlm_add_input(self, psz_name, psz_input):
"""Add a media's input MRL. This will add the specified one.
@param psz_name: the media to work on
@param psz_input: the input MRL
@return: 0 on success, -1 on error
"""
return libvlc_vlm_add_input(self, psz_name, psz_input)
if hasattr(dll, 'libvlc_vlm_set_loop'):
def vlm_set_loop(self, psz_name, b_loop):
"""Set a media's loop status.
@param psz_name: the media to work on
@param b_loop: the new status
@return: 0 on success, -1 on error
"""
return libvlc_vlm_set_loop(self, psz_name, b_loop)
if hasattr(dll, 'libvlc_vlm_set_mux'):
def vlm_set_mux(self, psz_name, psz_mux):
"""Set a media's vod muxer.
@param psz_name: the media to work on
@param psz_mux: the new muxer
@return: 0 on success, -1 on error
"""
return libvlc_vlm_set_mux(self, psz_name, psz_mux)
if hasattr(dll, 'libvlc_vlm_change_media'):
def vlm_change_media(self, psz_name, psz_input, psz_output, i_options, ppsz_options, b_enabled, b_loop):
"""Edit the parameters of a media. This will delete all existing inputs and
add the specified one.
@param psz_name: the name of the new broadcast
@param psz_input: the input MRL
@param psz_output: the output MRL (the parameter to the "sout" variable)
@param i_options: number of additional options
@param ppsz_options: additional options
@param b_enabled: boolean for enabling the new broadcast
@param b_loop: Should this broadcast be played in loop ?
@return: 0 on success, -1 on error
"""
return libvlc_vlm_change_media(self, psz_name, psz_input, psz_output, i_options, ppsz_options, b_enabled, b_loop)
if hasattr(dll, 'libvlc_vlm_play_media'):
def vlm_play_media(self, psz_name):
"""Play the named broadcast.
@param psz_name: the name of the broadcast
@return: 0 on success, -1 on error
"""
return libvlc_vlm_play_media(self, psz_name)
if hasattr(dll, 'libvlc_vlm_stop_media'):
def vlm_stop_media(self, psz_name):
"""Stop the named broadcast.
@param psz_name: the name of the broadcast
@return: 0 on success, -1 on error
"""
return libvlc_vlm_stop_media(self, psz_name)
if hasattr(dll, 'libvlc_vlm_pause_media'):
def vlm_pause_media(self, psz_name):
"""Pause the named broadcast.
@param psz_name: the name of the broadcast
@return: 0 on success, -1 on error
"""
return libvlc_vlm_pause_media(self, psz_name)
if hasattr(dll, 'libvlc_vlm_seek_media'):
def vlm_seek_media(self, psz_name, f_percentage):
"""Seek in the named broadcast.
@param psz_name: the name of the broadcast
@param f_percentage: the percentage to seek to
@return: 0 on success, -1 on error
"""
return libvlc_vlm_seek_media(self, psz_name, f_percentage)
if hasattr(dll, 'libvlc_vlm_show_media'):
def vlm_show_media(self, psz_name):
"""Return information about the named media as a JSON
string representation.
This function is mainly intended for debugging use,
if you want programmatic access to the state of
a vlm_media_instance_t, please use the corresponding
libvlc_vlm_get_media_instance_xxx -functions.
Currently there are no such functions available for
vlm_media_t though.
@param psz_name: the name of the media,
@return: string with information about named media, or NULL on error
"""
return libvlc_vlm_show_media(self, psz_name)
if hasattr(dll, 'libvlc_vlm_get_media_instance_position'):
def vlm_get_media_instance_position(self, psz_name, i_instance):
"""Get vlm_media instance position by name or instance id
@param psz_name: name of vlm media instance
@param i_instance: instance id
@return: position as float or -1. on error
"""
return libvlc_vlm_get_media_instance_position(self, psz_name, i_instance)
if hasattr(dll, 'libvlc_vlm_get_media_instance_time'):
def vlm_get_media_instance_time(self, psz_name, i_instance):
"""Get vlm_media instance time by name or instance id
@param psz_name: name of vlm media instance
@param i_instance: instance id
@return: time as integer or -1 on error
"""
return libvlc_vlm_get_media_instance_time(self, psz_name, i_instance)
if hasattr(dll, 'libvlc_vlm_get_media_instance_length'):
def vlm_get_media_instance_length(self, psz_name, i_instance):
"""Get vlm_media instance length by name or instance id
@param psz_name: name of vlm media instance
@param i_instance: instance id
@return: length of media item or -1 on error
"""
return libvlc_vlm_get_media_instance_length(self, psz_name, i_instance)
if hasattr(dll, 'libvlc_vlm_get_media_instance_rate'):
def vlm_get_media_instance_rate(self, psz_name, i_instance):
"""Get vlm_media instance playback rate by name or instance id
@param psz_name: name of vlm media instance
@param i_instance: instance id
@return: playback rate or -1 on error
"""
return libvlc_vlm_get_media_instance_rate(self, psz_name, i_instance)
if hasattr(dll, 'libvlc_vlm_get_media_instance_title'):
def vlm_get_media_instance_title(self, psz_name, i_instance):
"""Get vlm_media instance title number by name or instance id
\bug will always return 0
@param psz_name: name of vlm media instance
@param i_instance: instance id
@return: title as number or -1 on error
"""
return libvlc_vlm_get_media_instance_title(self, psz_name, i_instance)
if hasattr(dll, 'libvlc_vlm_get_media_instance_chapter'):
def vlm_get_media_instance_chapter(self, psz_name, i_instance):
"""Get vlm_media instance chapter number by name or instance id
\bug will always return 0
@param psz_name: name of vlm media instance
@param i_instance: instance id
@return: chapter as number or -1 on error
"""
return libvlc_vlm_get_media_instance_chapter(self, psz_name, i_instance)
if hasattr(dll, 'libvlc_vlm_get_media_instance_seekable'):
def vlm_get_media_instance_seekable(self, psz_name, i_instance):
"""Is libvlc instance seekable ?
\bug will always return 0
@param psz_name: name of vlm media instance
@param i_instance: instance id
@return: 1 if seekable, 0 if not, -1 if media does not exist
"""
return libvlc_vlm_get_media_instance_seekable(self, psz_name, i_instance)
if hasattr(dll, 'libvlc_vlm_get_event_manager'):
def vlm_get_event_manager(self):
"""Get libvlc_event_manager from a vlm media.
The p_event_manager is immutable, so you don't have to hold the lock
@return: libvlc_event_manager
"""
return libvlc_vlm_get_event_manager(self)
class Log(object):
def __new__(cls, pointer=None):
'''Internal method used for instanciating wrappers from ctypes.
'''
if pointer is None:
raise Exception("Internal method. Surely this class cannot be instanciated by itself.")
if pointer == 0:
return None
else:
o=object.__new__(cls)
o._as_parameter_=ctypes.c_void_p(pointer)
return o
@staticmethod
def from_param(arg):
'''(INTERNAL) ctypes parameter conversion method.
'''
return arg._as_parameter_
def __iter__(self):
return self.get_iterator()
def dump(self):
return [ str(m) for m in self ]
if hasattr(dll, 'libvlc_log_close'):
def close(self):
"""Close a VLC message log instance.
"""
return libvlc_log_close(self)
if hasattr(dll, 'libvlc_log_count'):
def count(self):
"""Returns the number of messages in a log instance.
@return: number of log messages, 0 if p_log is NULL
"""
return libvlc_log_count(self)
def __len__(self):
return libvlc_log_count(self)
if hasattr(dll, 'libvlc_log_clear'):
def clear(self):
"""Clear a log instance.
All messages in the log are removed. The log should be cleared on a
regular basis to avoid clogging.
"""
return libvlc_log_clear(self)
if hasattr(dll, 'libvlc_log_get_iterator'):
def get_iterator(self):
"""Allocate and returns a new iterator to messages in log.
@return: log iterator object or NULL on error
"""
return libvlc_log_get_iterator(self)
class LogIterator(object):
def __new__(cls, pointer=None):
'''Internal method used for instanciating wrappers from ctypes.
'''
if pointer is None:
raise Exception("Internal method. Surely this class cannot be instanciated by itself.")
if pointer == 0:
return None
else:
o=object.__new__(cls)
o._as_parameter_=ctypes.c_void_p(pointer)
return o
@staticmethod
def from_param(arg):
'''(INTERNAL) ctypes parameter conversion method.
'''
return arg._as_parameter_
def __iter__(self):
return self
def next(self):
if not self.has_next():
raise StopIteration
buf=LogMessage()
ret=libvlc_log_iterator_next(self, buf)
return ret.contents
if hasattr(dll, 'libvlc_log_iterator_free'):
def free(self):
"""Release a previoulsy allocated iterator.
"""
return libvlc_log_iterator_free(self)
if hasattr(dll, 'libvlc_log_iterator_has_next'):
def has_next(self):
"""Return whether log iterator has more messages.
@return: true if iterator has more message objects, else false
"""
return libvlc_log_iterator_has_next(self)
class Media(object):
def __new__(cls, pointer=None):
'''Internal method used for instanciating wrappers from ctypes.
'''
if pointer is None:
raise Exception("Internal method. Surely this class cannot be instanciated by itself.")
if pointer == 0:
return None
else:
o=object.__new__(cls)
o._as_parameter_=ctypes.c_void_p(pointer)
return o
@staticmethod
def from_param(arg):
'''(INTERNAL) ctypes parameter conversion method.
'''
return arg._as_parameter_
def add_options(self, *list_of_options):
"""Add a list of options to the media.
Options must be written without the double-dash, e.g.:
m.add_options('sub-filter=marq@test{marquee=Hello}', 'video-filter=invert')
Note that you also can directly pass these options in the Instance.media_new method:
m=instance.media_new( 'foo.avi', 'sub-filter=marq@test{marquee=Hello}', 'video-filter=invert')
"""
for o in list_of_options:
self.add_option(o)
if hasattr(dll, 'libvlc_media_add_option'):
def add_option(self, ppsz_options):
"""Add an option to the media.
This option will be used to determine how the media_player will
read the media. This allows to use VLC's advanced
reading/streaming options on a per-media basis.
The options are detailed in vlc --long-help, for instance "--sout-all"
@param ppsz_options: the options (as a string)
"""
return libvlc_media_add_option(self, ppsz_options)
if hasattr(dll, 'libvlc_media_add_option_flag'):
def add_option_flag(self, ppsz_options, i_flags):
"""Add an option to the media with configurable flags.
This option will be used to determine how the media_player will
read the media. This allows to use VLC's advanced
reading/streaming options on a per-media basis.
The options are detailed in vlc --long-help, for instance "--sout-all"
@param ppsz_options: the options (as a string)
@param i_flags: the flags for this option
"""
return libvlc_media_add_option_flag(self, ppsz_options, i_flags)
if hasattr(dll, 'libvlc_media_retain'):
def retain(self):
"""Retain a reference to a media descriptor object (libvlc_media_t). Use
libvlc_media_release() to decrement the reference count of a
media descriptor object.
"""
return libvlc_media_retain(self)
if hasattr(dll, 'libvlc_media_release'):
def release(self):
"""Decrement the reference count of a media descriptor object. If the
reference count is 0, then libvlc_media_release() will release the
media descriptor object. It will send out an libvlc_MediaFreed event
to all listeners. If the media descriptor object has been released it
should not be used again.
"""
return libvlc_media_release(self)
if hasattr(dll, 'libvlc_media_get_mrl'):
def get_mrl(self):
"""Get the media resource locator (mrl) from a media descriptor object
@return: string with mrl of media descriptor object
"""
return libvlc_media_get_mrl(self)
if hasattr(dll, 'libvlc_media_duplicate'):
def duplicate(self):
"""Duplicate a media descriptor object.
"""
return libvlc_media_duplicate(self)
if hasattr(dll, 'libvlc_media_get_meta'):
def get_meta(self, e_meta):
"""Read the meta of the media.
If the media has not yet been parsed this will return NULL.
This methods automatically calls libvlc_media_parse_async(), so after calling
it you may receive a libvlc_MediaMetaChanged event. If you prefer a synchronous
version ensure that you call libvlc_media_parse() before get_meta().
See libvlc_media_parse
See libvlc_media_parse_async
See libvlc_MediaMetaChanged
@param e_meta: the meta to read
@return: the media's meta
"""
return libvlc_media_get_meta(self, e_meta)
if hasattr(dll, 'libvlc_media_set_meta'):
def set_meta(self, e_meta, psz_value):
"""Set the meta of the media (this function will not save the meta, call
libvlc_media_save_meta in order to save the meta)
@param e_meta: the meta to write
@param psz_value: the media's meta
"""
return libvlc_media_set_meta(self, e_meta, psz_value)
if hasattr(dll, 'libvlc_media_save_meta'):
def save_meta(self):
"""Save the meta previously set
@return: true if the write operation was successfull
"""
return libvlc_media_save_meta(self)
if hasattr(dll, 'libvlc_media_get_state'):
def get_state(self):
"""Get current state of media descriptor object. Possible media states
are defined in libvlc_structures.c ( libvlc_NothingSpecial=0,
libvlc_Opening, libvlc_Buffering, libvlc_Playing, libvlc_Paused,
libvlc_Stopped, libvlc_Ended,
libvlc_Error).
See libvlc_state_t
@return: state of media descriptor object
"""
return libvlc_media_get_state(self)
if hasattr(dll, 'libvlc_media_get_stats'):
def get_stats(self, p_stats):
"""Get the current statistics about the media
@param p_stats:: structure that contain the statistics about the media
@return: true if the statistics are available, false otherwise
"""
return libvlc_media_get_stats(self, p_stats)
if hasattr(dll, 'libvlc_media_subitems'):
def subitems(self):
"""Get subitems of media descriptor object. This will increment
the reference count of supplied media descriptor object. Use
libvlc_media_list_release() to decrement the reference counting.
@return: list of media descriptor subitems or NULL
"""
return libvlc_media_subitems(self)
if hasattr(dll, 'libvlc_media_event_manager'):
def event_manager(self):
"""Get event manager from media descriptor object.
NOTE: this function doesn't increment reference counting.
@return: event manager object
"""
return libvlc_media_event_manager(self)
if hasattr(dll, 'libvlc_media_get_duration'):
def get_duration(self):
"""Get duration (in ms) of media descriptor object item.
@return: duration of media item or -1 on error
"""
return libvlc_media_get_duration(self)
if hasattr(dll, 'libvlc_media_parse'):
def parse(self):
"""Parse a media.
This fetches (local) meta data and tracks information.
The method is synchronous.
See libvlc_media_parse_async
See libvlc_media_get_meta
See libvlc_media_get_tracks_info
"""
return libvlc_media_parse(self)
if hasattr(dll, 'libvlc_media_parse_async'):
def parse_async(self):
"""Parse a media.
This fetches (local) meta data and tracks information.
The method is the asynchronous of libvlc_media_parse().
To track when this is over you can listen to libvlc_MediaParsedChanged
event. However if the media was already parsed you will not receive this
event.
See libvlc_media_parse
See libvlc_MediaParsedChanged
See libvlc_media_get_meta
See libvlc_media_get_tracks_info
"""
return libvlc_media_parse_async(self)
if hasattr(dll, 'libvlc_media_is_parsed'):
def is_parsed(self):
"""Get Parsed status for media descriptor object.
See libvlc_MediaParsedChanged
@return: true if media object has been parsed otherwise it returns false
"""
return libvlc_media_is_parsed(self)
if hasattr(dll, 'libvlc_media_set_user_data'):
def set_user_data(self, p_new_user_data):
"""Sets media descriptor's user_data. user_data is specialized data
accessed by the host application, VLC.framework uses it as a pointer to
an native object that references a libvlc_media_t pointer
@param p_new_user_data: pointer to user data
"""
return libvlc_media_set_user_data(self, p_new_user_data)
if hasattr(dll, 'libvlc_media_get_user_data'):
def get_user_data(self):
"""Get media descriptor's user_data. user_data is specialized data
accessed by the host application, VLC.framework uses it as a pointer to
an native object that references a libvlc_media_t pointer
"""
return libvlc_media_get_user_data(self)
if hasattr(dll, 'libvlc_media_get_tracks_info'):
def get_tracks_info(self, tracks):
"""Get media descriptor's elementary streams description
Note, you need to play the media _one_ time with --sout="#description"
Not doing this will result in an empty array, and doing it more than once
will duplicate the entries in the array each time. Something like this:
@begincode
libvlc_media_player_t *player = libvlc_media_player_new_from_media(media);
libvlc_media_add_option_flag(media, "sout=\"#description\"");
libvlc_media_player_play(player);
// ... wait until playing
libvlc_media_player_release(player);
@endcode
This is very likely to change in next release, and be done at the parsing
phase.
@param tracks: address to store an allocated array of Elementary Streams
"""
return libvlc_media_get_tracks_info(self, tracks)
if hasattr(dll, 'libvlc_media_player_new_from_media'):
def player_new_from_media(self):
"""Create a Media Player object from a Media
@return: a new media player object, or NULL on error.
"""
return libvlc_media_player_new_from_media(self)
class MediaDiscoverer(object):
def __new__(cls, pointer=None):
'''Internal method used for instanciating wrappers from ctypes.
'''
if pointer is None:
raise Exception("Internal method. Surely this class cannot be instanciated by itself.")
if pointer == 0:
return None
else:
o=object.__new__(cls)
o._as_parameter_=ctypes.c_void_p(pointer)
return o
@staticmethod
def from_param(arg):
'''(INTERNAL) ctypes parameter conversion method.
'''
return arg._as_parameter_
if hasattr(dll, 'libvlc_media_discoverer_release'):
def release(self):
"""Release media discover object. If the reference count reaches 0, then
the object will be released.
"""
return libvlc_media_discoverer_release(self)
if hasattr(dll, 'libvlc_media_discoverer_localized_name'):
def localized_name(self):
"""Get media service discover object its localized name.
@return: localized name
"""
return libvlc_media_discoverer_localized_name(self)
if hasattr(dll, 'libvlc_media_discoverer_media_list'):
def media_list(self):
"""Get media service discover media list.
@return: list of media items
"""
return libvlc_media_discoverer_media_list(self)
if hasattr(dll, 'libvlc_media_discoverer_event_manager'):
def event_manager(self):
"""Get event manager from media service discover object.
@return: event manager object.
"""
return libvlc_media_discoverer_event_manager(self)
if hasattr(dll, 'libvlc_media_discoverer_is_running'):
def is_running(self):
"""Query if media service discover object is running.
@return: true if running, false if not
"""
return libvlc_media_discoverer_is_running(self)
class MediaLibrary(object):
def __new__(cls, pointer=None):
'''Internal method used for instanciating wrappers from ctypes.
'''
if pointer is None:
raise Exception("Internal method. Surely this class cannot be instanciated by itself.")
if pointer == 0:
return None
else:
o=object.__new__(cls)
o._as_parameter_=ctypes.c_void_p(pointer)
return o
@staticmethod
def from_param(arg):
'''(INTERNAL) ctypes parameter conversion method.
'''
return arg._as_parameter_
if hasattr(dll, 'libvlc_media_library_release'):
def release(self):
"""Release media library object. This functions decrements the
reference count of the media library object. If it reaches 0,
then the object will be released.
"""
return libvlc_media_library_release(self)
if hasattr(dll, 'libvlc_media_library_retain'):
def retain(self):
"""Retain a reference to a media library object. This function will
increment the reference counting for this object. Use
libvlc_media_library_release() to decrement the reference count.
"""
return libvlc_media_library_retain(self)
if hasattr(dll, 'libvlc_media_library_load'):
def load(self):
"""Load media library.
@return: 0 on success, -1 on error
"""
return libvlc_media_library_load(self)
if hasattr(dll, 'libvlc_media_library_media_list'):
def media_list(self):
"""Get media library subitems.
@return: media list subitems
"""
return libvlc_media_library_media_list(self)
class MediaList(object):
def __new__(cls, pointer=None):
'''Internal method used for instanciating wrappers from ctypes.
'''
if pointer is None:
raise Exception("Internal method. Surely this class cannot be instanciated by itself.")
if pointer == 0:
return None
else:
o=object.__new__(cls)
o._as_parameter_=ctypes.c_void_p(pointer)
return o
@staticmethod
def from_param(arg):
'''(INTERNAL) ctypes parameter conversion method.
'''
return arg._as_parameter_
if hasattr(dll, 'libvlc_media_list_release'):
def release(self):
"""Release media list created with libvlc_media_list_new().
"""
return libvlc_media_list_release(self)
if hasattr(dll, 'libvlc_media_list_retain'):
def retain(self):
"""Retain reference to a media list
"""
return libvlc_media_list_retain(self)
if hasattr(dll, 'libvlc_media_list_set_media'):
def set_media(self, p_md):
"""Associate media instance with this media list instance.
If another media instance was present it will be released.
The libvlc_media_list_lock should NOT be held upon entering this function.
@param p_md: media instance to add
"""
return libvlc_media_list_set_media(self, p_md)
if hasattr(dll, 'libvlc_media_list_media'):
def media(self):
"""Get media instance from this media list instance. This action will increase
the refcount on the media instance.
The libvlc_media_list_lock should NOT be held upon entering this function.
@return: media instance
"""
return libvlc_media_list_media(self)
if hasattr(dll, 'libvlc_media_list_add_media'):
def add_media(self, p_md):
"""Add media instance to media list
The libvlc_media_list_lock should be held upon entering this function.
@param p_md: a media instance
@return: 0 on success, -1 if the media list is read-only
"""
return libvlc_media_list_add_media(self, p_md)
if hasattr(dll, 'libvlc_media_list_insert_media'):
def insert_media(self, p_md, i_pos):
"""Insert media instance in media list on a position
The libvlc_media_list_lock should be held upon entering this function.
@param p_md: a media instance
@param i_pos: position in array where to insert
@return: 0 on success, -1 if the media list si read-only
"""
return libvlc_media_list_insert_media(self, p_md, i_pos)
if hasattr(dll, 'libvlc_media_list_remove_index'):
def remove_index(self, i_pos):
"""Remove media instance from media list on a position
The libvlc_media_list_lock should be held upon entering this function.
@param i_pos: position in array where to insert
@return: 0 on success, -1 if the list is read-only or the item was not found
"""
return libvlc_media_list_remove_index(self, i_pos)
if hasattr(dll, 'libvlc_media_list_count'):
def count(self):
"""Get count on media list items
The libvlc_media_list_lock should be held upon entering this function.
@return: number of items in media list
"""
return libvlc_media_list_count(self)
def __len__(self):
return libvlc_media_list_count(self)
if hasattr(dll, 'libvlc_media_list_item_at_index'):
def item_at_index(self, i_pos):
"""List media instance in media list at a position
The libvlc_media_list_lock should be held upon entering this function.
@param i_pos: position in array where to insert
@return: media instance at position i_pos, or NULL if not found.
"""
return libvlc_media_list_item_at_index(self, i_pos)
def __getitem__(self, i):
return libvlc_media_list_item_at_index(self, i)
def __iter__(self):
for i in xrange(len(self)):
yield self[i]
if hasattr(dll, 'libvlc_media_list_index_of_item'):
def index_of_item(self, p_md):
"""Find index position of List media instance in media list.
Warning: the function will return the first matched position.
The libvlc_media_list_lock should be held upon entering this function.
@param p_md: media list instance
@return: position of media instance
"""
return libvlc_media_list_index_of_item(self, p_md)
if hasattr(dll, 'libvlc_media_list_is_readonly'):
def is_readonly(self):
"""This indicates if this media list is read-only from a user point of view
@return: 0 on readonly, 1 on readwrite
"""
return libvlc_media_list_is_readonly(self)
if hasattr(dll, 'libvlc_media_list_lock'):
def lock(self):
"""Get lock on media list items
"""
return libvlc_media_list_lock(self)
if hasattr(dll, 'libvlc_media_list_unlock'):
def unlock(self):
"""Release lock on media list items
The libvlc_media_list_lock should be held upon entering this function.
"""
return libvlc_media_list_unlock(self)
if hasattr(dll, 'libvlc_media_list_event_manager'):
def event_manager(self):
"""Get libvlc_event_manager from this media list instance.
The p_event_manager is immutable, so you don't have to hold the lock
@return: libvlc_event_manager
"""
return libvlc_media_list_event_manager(self)
class MediaListPlayer(object):
"""Create a new MediaPlayer instance.
It may take as parameter either:
- a vlc.Instance
- nothing
"""
@staticmethod
def from_param(arg):
'''(INTERNAL) ctypes parameter conversion method.
'''
return arg._as_parameter_
def __new__(cls, *p):
if p and p[0] == 0:
return None
elif p and isinstance(p[0], (int, long)):
# instance creation from ctypes
o=object.__new__(cls)
o._as_parameter_=ctypes.c_void_p(p[0])
return o
elif len(p) == 1 and isinstance(p[0], (tuple, list)):
p=p[0]
if p and isinstance(p[0], Instance):
return p[0].media_list_player_new()
else:
i=Instance()
o=i.media_list_player_new()
return o
def get_instance(self):
"""Return the associated vlc.Instance.
"""
return self._instance
if hasattr(dll, 'libvlc_media_list_player_release'):
def release(self):
"""Release media_list_player.
"""
return libvlc_media_list_player_release(self)
if hasattr(dll, 'libvlc_media_list_player_event_manager'):
def event_manager(self):
"""Return the event manager of this media_list_player.
@return: the event manager
"""
return libvlc_media_list_player_event_manager(self)
if hasattr(dll, 'libvlc_media_list_player_set_media_player'):
def set_media_player(self, p_mi):
"""Replace media player in media_list_player with this instance.
@param p_mi: media player instance
"""
return libvlc_media_list_player_set_media_player(self, p_mi)
if hasattr(dll, 'libvlc_media_list_player_set_media_list'):
def set_media_list(self, p_mlist):
"""Set the media list associated with the player
@param p_mlist: list of media
"""
return libvlc_media_list_player_set_media_list(self, p_mlist)
if hasattr(dll, 'libvlc_media_list_player_play'):
def play(self):
"""Play media list
"""
return libvlc_media_list_player_play(self)
if hasattr(dll, 'libvlc_media_list_player_pause'):
def pause(self):
"""Pause media list
"""
return libvlc_media_list_player_pause(self)
if hasattr(dll, 'libvlc_media_list_player_is_playing'):
def is_playing(self):
"""Is media list playing?
@return: true for playing and false for not playing
"""
return libvlc_media_list_player_is_playing(self)
if hasattr(dll, 'libvlc_media_list_player_get_state'):
def get_state(self):
"""Get current libvlc_state of media list player
@return: libvlc_state_t for media list player
"""
return libvlc_media_list_player_get_state(self)
if hasattr(dll, 'libvlc_media_list_player_play_item_at_index'):
def play_item_at_index(self, i_index):
"""Play media list item at position index
@param i_index: index in media list to play
@return: 0 upon success -1 if the item wasn't found
"""
return libvlc_media_list_player_play_item_at_index(self, i_index)
def __getitem__(self, i):
return libvlc_media_list_player_play_item_at_index(self, i)
def __iter__(self):
for i in xrange(len(self)):
yield self[i]
if hasattr(dll, 'libvlc_media_list_player_play_item'):
def play_item(self, p_md):
"""Play the given media item
@param p_md: the media instance
@return: 0 upon success, -1 if the media is not part of the media list
"""
return libvlc_media_list_player_play_item(self, p_md)
if hasattr(dll, 'libvlc_media_list_player_stop'):
def stop(self):
"""Stop playing media list
"""
return libvlc_media_list_player_stop(self)
if hasattr(dll, 'libvlc_media_list_player_next'):
def next(self):
"""Play next item from media list
@return: 0 upon success -1 if there is no next item
"""
return libvlc_media_list_player_next(self)
if hasattr(dll, 'libvlc_media_list_player_previous'):
def previous(self):
"""Play previous item from media list
@return: 0 upon success -1 if there is no previous item
"""
return libvlc_media_list_player_previous(self)
if hasattr(dll, 'libvlc_media_list_player_set_playback_mode'):
def set_playback_mode(self, e_mode):
"""Sets the playback mode for the playlist
@param e_mode: playback mode specification
"""
return libvlc_media_list_player_set_playback_mode(self, e_mode)
class MediaPlayer(object):
"""Create a new MediaPlayer instance.
It may take as parameter either:
- a string (media URI). In this case, a vlc.Instance will be created.
- a vlc.Instance
"""
@staticmethod
def from_param(arg):
'''(INTERNAL) ctypes parameter conversion method.
'''
return arg._as_parameter_
def __new__(cls, *p):
if p and p[0] == 0:
return None
elif p and isinstance(p[0], (int, long)):
# instance creation from ctypes
o=object.__new__(cls)
o._as_parameter_=ctypes.c_void_p(p[0])
return o
if p and isinstance(p[0], Instance):
return p[0].media_player_new()
else:
i=Instance()
o=i.media_player_new()
if p:
o.set_media(i.media_new(p[0]))
return o
def get_instance(self):
"""Return the associated vlc.Instance.
"""
return self._instance
def set_mrl(self, mrl, *options):
"""Set the MRL to play.
@param mrl: The MRL
@param options: a list of options
@return The Media object
"""
m = self.get_instance().media_new(mrl, *options)
self.set_media(m)
return m
def video_get_spu_description(self):
"""Get the description of available video subtitles.
"""
return track_description_list(libvlc_video_get_spu_description(self))
def video_get_title_description(self):
"""Get the description of available titles.
"""
return track_description_list(libvlc_video_get_title_description(self))
def video_get_chapter_description(self, title):
"""Get the description of available chapters for specific title.
@param i_title selected title (int)
"""
return track_description_list(libvlc_video_get_chapter_description(self, title))
def video_get_track_description(self):
"""Get the description of available video tracks.
"""
return track_description_list(libvlc_video_get_track_description(self))
def audio_get_track_description(self):
"""Get the description of available audio tracks.
"""
return track_description_list(libvlc_audio_get_track_description(self))
if hasattr(dll, 'libvlc_media_player_release'):
def release(self):
"""Release a media_player after use
Decrement the reference count of a media player object. If the
reference count is 0, then libvlc_media_player_release() will
release the media player object. If the media player object
has been released, then it should not be used again.
"""
return libvlc_media_player_release(self)
if hasattr(dll, 'libvlc_media_player_retain'):
def retain(self):
"""Retain a reference to a media player object. Use
libvlc_media_player_release() to decrement reference count.
"""
return libvlc_media_player_retain(self)
if hasattr(dll, 'libvlc_media_player_set_media'):
def set_media(self, p_md):
"""Set the media that will be used by the media_player. If any,
previous md will be released.
@param p_md: the Media. Afterwards the p_md can be safely
"""
return libvlc_media_player_set_media(self, p_md)
if hasattr(dll, 'libvlc_media_player_get_media'):
def get_media(self):
"""Get the media used by the media_player.
@return: the media associated with p_mi, or NULL if no
"""
return libvlc_media_player_get_media(self)
if hasattr(dll, 'libvlc_media_player_event_manager'):
def event_manager(self):
"""Get the Event Manager from which the media player send event.
@return: the event manager associated with p_mi
"""
return libvlc_media_player_event_manager(self)
if hasattr(dll, 'libvlc_media_player_is_playing'):
def is_playing(self):
"""is_playing
@return: 1 if the media player is playing, 0 otherwise
"""
return libvlc_media_player_is_playing(self)
if hasattr(dll, 'libvlc_media_player_play'):
def play(self):
"""Play
@return: 0 if playback started (and was already started), or -1 on error.
"""
return libvlc_media_player_play(self)
if hasattr(dll, 'libvlc_media_player_set_pause'):
def set_pause(self, do_pause):
"""Pause or resume (no effect if there is no media)
@param do_pause: play/resume if zero, pause if non-zero
"""
return libvlc_media_player_set_pause(self, do_pause)
if hasattr(dll, 'libvlc_media_player_pause'):
def pause(self):
"""Toggle pause (no effect if there is no media)
"""
return libvlc_media_player_pause(self)
if hasattr(dll, 'libvlc_media_player_stop'):
def stop(self):
"""Stop (no effect if there is no media)
"""
return libvlc_media_player_stop(self)
if hasattr(dll, 'libvlc_video_set_format'):
def video_set_format(self, chroma, width, height, pitch):
"""Set decoded video chroma and dimensions. This only works in combination with
libvlc_video_set_callbacks().
@param chroma: a four-characters string identifying the chroma
@param width: pixel width
@param height: pixel height
@param pitch: line pitch (in bytes)
"""
return libvlc_video_set_format(self, chroma, width, height, pitch)
if hasattr(dll, 'libvlc_media_player_set_nsobject'):
def set_nsobject(self, drawable):
"""Set the NSView handler where the media player should render its video output.
Use the vout called "macosx".
The drawable is an NSObject that follow the VLCOpenGLVideoViewEmbedding
protocol:
@begincode
\@protocol VLCOpenGLVideoViewEmbedding <NSObject>
- (void)addVoutSubview:(NSView *)view;
- (void)removeVoutSubview:(NSView *)view;
\@end
@endcode
Or it can be an NSView object.
If you want to use it along with Qt4 see the QMacCocoaViewContainer. Then
the following code should work:
@begincode
{
NSView *video = [[NSView alloc] init];
QMacCocoaViewContainer *container = new QMacCocoaViewContainer(video, parent);
libvlc_media_player_set_nsobject(mp, video);
[video release];
}
@endcode
You can find a live example in VLCVideoView in VLCKit.framework.
@param drawable: the drawable that is either an NSView or an object following
"""
return libvlc_media_player_set_nsobject(self, drawable)
if hasattr(dll, 'libvlc_media_player_get_nsobject'):
def get_nsobject(self):
"""Get the NSView handler previously set with libvlc_media_player_set_nsobject().
@return: the NSView handler or 0 if none where set
"""
return libvlc_media_player_get_nsobject(self)
if hasattr(dll, 'libvlc_media_player_set_agl'):
def set_agl(self, drawable):
"""Set the agl handler where the media player should render its video output.
@param drawable: the agl handler
"""
return libvlc_media_player_set_agl(self, drawable)
if hasattr(dll, 'libvlc_media_player_get_agl'):
def get_agl(self):
"""Get the agl handler previously set with libvlc_media_player_set_agl().
@return: the agl handler or 0 if none where set
"""
return libvlc_media_player_get_agl(self)
if hasattr(dll, 'libvlc_media_player_set_xwindow'):
def set_xwindow(self, drawable):
"""Set an X Window System drawable where the media player should render its
video output. If LibVLC was built without X11 output support, then this has
no effects.
The specified identifier must correspond to an existing Input/Output class
X11 window. Pixmaps are <b>not</b> supported. The caller shall ensure that
the X11 server is the same as the one the VLC instance has been configured
with.
@param drawable: the ID of the X window
"""
return libvlc_media_player_set_xwindow(self, drawable)
if hasattr(dll, 'libvlc_media_player_get_xwindow'):
def get_xwindow(self):
"""Get the X Window System window identifier previously set with
libvlc_media_player_set_xwindow(). Note that this will return the identifier
even if VLC is not currently using it (for instance if it is playing an
audio-only input).
@return: an X window ID, or 0 if none where set.
"""
return libvlc_media_player_get_xwindow(self)
if hasattr(dll, 'libvlc_media_player_set_hwnd'):
def set_hwnd(self, drawable):
"""Set a Win32/Win64 API window handle (HWND) where the media player should
render its video output. If LibVLC was built without Win32/Win64 API output
support, then this has no effects.
@param drawable: windows handle of the drawable
"""
return libvlc_media_player_set_hwnd(self, drawable)
if hasattr(dll, 'libvlc_media_player_get_hwnd'):
def get_hwnd(self):
"""Get the Windows API window handle (HWND) previously set with
libvlc_media_player_set_hwnd(). The handle will be returned even if LibVLC
is not currently outputting any video to it.
@return: a window handle or NULL if there are none.
"""
return libvlc_media_player_get_hwnd(self)
if hasattr(dll, 'libvlc_media_player_get_length'):
def get_length(self):
"""Get the current movie length (in ms).
@return: the movie length (in ms), or -1 if there is no media.
"""
return libvlc_media_player_get_length(self)
if hasattr(dll, 'libvlc_media_player_get_time'):
def get_time(self):
"""Get the current movie time (in ms).
@return: the movie time (in ms), or -1 if there is no media.
"""
return libvlc_media_player_get_time(self)
if hasattr(dll, 'libvlc_media_player_set_time'):
def set_time(self, i_time):
"""Set the movie time (in ms). This has no effect if no media is being played.
Not all formats and protocols support this.
@param i_time: the movie time (in ms).
"""
return libvlc_media_player_set_time(self, i_time)
if hasattr(dll, 'libvlc_media_player_get_position'):
def get_position(self):
"""Get movie position.
@return: movie position, or -1. in case of error
"""
return libvlc_media_player_get_position(self)
if hasattr(dll, 'libvlc_media_player_set_position'):
def set_position(self, f_pos):
"""Set movie position. This has no effect if playback is not enabled.
This might not work depending on the underlying input format and protocol.
@param f_pos: the position
"""
return libvlc_media_player_set_position(self, f_pos)
if hasattr(dll, 'libvlc_media_player_set_chapter'):
def set_chapter(self, i_chapter):
"""Set movie chapter (if applicable).
@param i_chapter: chapter number to play
"""
return libvlc_media_player_set_chapter(self, i_chapter)
if hasattr(dll, 'libvlc_media_player_get_chapter'):
def get_chapter(self):
"""Get movie chapter.
@return: chapter number currently playing, or -1 if there is no media.
"""
return libvlc_media_player_get_chapter(self)
if hasattr(dll, 'libvlc_media_player_get_chapter_count'):
def get_chapter_count(self):
"""Get movie chapter count
@return: number of chapters in movie, or -1.
"""
return libvlc_media_player_get_chapter_count(self)
if hasattr(dll, 'libvlc_media_player_will_play'):
def will_play(self):
"""Is the player able to play
@return: boolean
"""
return libvlc_media_player_will_play(self)
if hasattr(dll, 'libvlc_media_player_get_chapter_count_for_title'):
def get_chapter_count_for_title(self, i_title):
"""Get title chapter count
@param i_title: title
@return: number of chapters in title, or -1
"""
return libvlc_media_player_get_chapter_count_for_title(self, i_title)
if hasattr(dll, 'libvlc_media_player_set_title'):
def set_title(self, i_title):
"""Set movie title
@param i_title: title number to play
"""
return libvlc_media_player_set_title(self, i_title)
if hasattr(dll, 'libvlc_media_player_get_title'):
def get_title(self):
"""Get movie title
@return: title number currently playing, or -1
"""
return libvlc_media_player_get_title(self)
if hasattr(dll, 'libvlc_media_player_get_title_count'):
def get_title_count(self):
"""Get movie title count
@return: title number count, or -1
"""
return libvlc_media_player_get_title_count(self)
if hasattr(dll, 'libvlc_media_player_previous_chapter'):
def previous_chapter(self):
"""Set previous chapter (if applicable)
"""
return libvlc_media_player_previous_chapter(self)
if hasattr(dll, 'libvlc_media_player_next_chapter'):
def next_chapter(self):
"""Set next chapter (if applicable)
"""
return libvlc_media_player_next_chapter(self)
if hasattr(dll, 'libvlc_media_player_get_rate'):
def get_rate(self):
"""Get the requested movie play rate.
@warning Depending on the underlying media, the requested rate may be
different from the real playback rate.
@return: movie play rate
"""
return libvlc_media_player_get_rate(self)
if hasattr(dll, 'libvlc_media_player_set_rate'):
def set_rate(self, rate):
"""Set movie play rate
@param rate: movie play rate to set
@return: -1 if an error was detected, 0 otherwise (but even then, it might
"""
return libvlc_media_player_set_rate(self, rate)
if hasattr(dll, 'libvlc_media_player_get_state'):
def get_state(self):
"""Get current movie state
@return: the current state of the media player (playing, paused, ...) See libvlc_state_t
"""
return libvlc_media_player_get_state(self)
if hasattr(dll, 'libvlc_media_player_get_fps'):
def get_fps(self):
"""Get movie fps rate
@return: frames per second (fps) for this playing movie, or 0 if unspecified
"""
return libvlc_media_player_get_fps(self)
if hasattr(dll, 'libvlc_media_player_has_vout'):
def has_vout(self):
"""How many video outputs does this media player have?
@return: the number of video outputs
"""
return libvlc_media_player_has_vout(self)
if hasattr(dll, 'libvlc_media_player_is_seekable'):
def is_seekable(self):
"""Is this media player seekable?
@return: true if the media player can seek
"""
return libvlc_media_player_is_seekable(self)
if hasattr(dll, 'libvlc_media_player_can_pause'):
def can_pause(self):
"""Can this media player be paused?
@return: true if the media player can pause
"""
return libvlc_media_player_can_pause(self)
if hasattr(dll, 'libvlc_media_player_next_frame'):
def next_frame(self):
"""Display the next frame (if supported)
"""
return libvlc_media_player_next_frame(self)
if hasattr(dll, 'libvlc_toggle_fullscreen'):
def toggle_fullscreen(self):
"""Toggle fullscreen status on non-embedded video outputs.
@warning The same limitations applies to this function
as to libvlc_set_fullscreen().
"""
return libvlc_toggle_fullscreen(self)
if hasattr(dll, 'libvlc_set_fullscreen'):
def set_fullscreen(self, b_fullscreen):
"""Enable or disable fullscreen.
@warning With most window managers, only a top-level windows can be in
full-screen mode. Hence, this function will not operate properly if
libvlc_media_player_set_xwindow() was used to embed the video in a
non-top-level window. In that case, the embedding window must be reparented
to the root window <b>before</b> fullscreen mode is enabled. You will want
to reparent it back to its normal parent when disabling fullscreen.
@param b_fullscreen: boolean for fullscreen status
"""
return libvlc_set_fullscreen(self, b_fullscreen)
if hasattr(dll, 'libvlc_get_fullscreen'):
def get_fullscreen(self):
"""Get current fullscreen status.
@return: the fullscreen status (boolean)
"""
return libvlc_get_fullscreen(self)
if hasattr(dll, 'libvlc_video_set_key_input'):
def video_set_key_input(self, on):
"""Enable or disable key press events handling, according to the LibVLC hotkeys
configuration. By default and for historical reasons, keyboard events are
handled by the LibVLC video widget.
\note On X11, there can be only one subscriber for key press and mouse
click events per window. If your application has subscribed to those events
for the X window ID of the video widget, then LibVLC will not be able to
handle key presses and mouse clicks in any case.
\warning This function is only implemented for X11 and Win32 at the moment.
@param on: true to handle key press events, false to ignore them.
"""
return libvlc_video_set_key_input(self, on)
if hasattr(dll, 'libvlc_video_set_mouse_input'):
def video_set_mouse_input(self, on):
"""Enable or disable mouse click events handling. By default, those events are
handled. This is needed for DVD menus to work, as well as a few video
filters such as "puzzle".
\note See also libvlc_video_set_key_input().
\warning This function is only implemented for X11 and Win32 at the moment.
@param on: true to handle mouse click events, false to ignore them.
"""
return libvlc_video_set_mouse_input(self, on)
if hasattr(dll, 'libvlc_video_get_size'):
def video_get_size(self, num, px, py):
"""Get the pixel dimensions of a video.
@param num: number of the video (starting from, and most commonly 0)
@param px: pointer to get the pixel width [OUT]
@param py: pointer to get the pixel height [OUT]
@return: 0 on success, -1 if the specified video does not exist
"""
return libvlc_video_get_size(self, num, px, py)
if hasattr(dll, 'libvlc_video_get_cursor'):
def video_get_cursor(self, num, px, py):
"""Get the mouse pointer coordinates over a video.
Coordinates are expressed in terms of the decoded video resolution,
<b>not</b> in terms of pixels on the screen/viewport (to get the latter,
you can query your windowing system directly).
Either of the coordinates may be negative or larger than the corresponding
dimension of the video, if the cursor is outside the rendering area.
@warning The coordinates may be out-of-date if the pointer is not located
on the video rendering area. LibVLC does not track the pointer if it is
outside of the video widget.
@note LibVLC does not support multiple pointers (it does of course support
multiple input devices sharing the same pointer) at the moment.
@param num: number of the video (starting from, and most commonly 0)
@param px: pointer to get the abscissa [OUT]
@param py: pointer to get the ordinate [OUT]
@return: 0 on success, -1 if the specified video does not exist
"""
return libvlc_video_get_cursor(self, num, px, py)
if hasattr(dll, 'libvlc_video_get_scale'):
def video_get_scale(self):
"""Get the current video scaling factor.
See also libvlc_video_set_scale().
@return: the currently configured zoom factor, or 0. if the video is set
"""
return libvlc_video_get_scale(self)
if hasattr(dll, 'libvlc_video_set_scale'):
def video_set_scale(self, f_factor):
"""Set the video scaling factor. That is the ratio of the number of pixels on
screen to the number of pixels in the original decoded video in each
dimension. Zero is a special value; it will adjust the video to the output
window/drawable (in windowed mode) or the entire screen.
Note that not all video outputs support scaling.
@param f_factor: the scaling factor, or zero
"""
return libvlc_video_set_scale(self, f_factor)
if hasattr(dll, 'libvlc_video_get_aspect_ratio'):
def video_get_aspect_ratio(self):
"""Get current video aspect ratio.
@return: the video aspect ratio or NULL if unspecified
"""
return libvlc_video_get_aspect_ratio(self)
if hasattr(dll, 'libvlc_video_set_aspect_ratio'):
def video_set_aspect_ratio(self, psz_aspect):
"""Set new video aspect ratio.
@param psz_aspect: new video aspect-ratio or NULL to reset to default
"""
return libvlc_video_set_aspect_ratio(self, psz_aspect)
if hasattr(dll, 'libvlc_video_get_spu'):
def video_get_spu(self):
"""Get current video subtitle.
@return: the video subtitle selected, or -1 if none
"""
return libvlc_video_get_spu(self)
if hasattr(dll, 'libvlc_video_get_spu_count'):
def video_get_spu_count(self):
"""Get the number of available video subtitles.
@return: the number of available video subtitles
"""
return libvlc_video_get_spu_count(self)
if hasattr(dll, 'libvlc_video_set_spu'):
def video_set_spu(self, i_spu):
"""Set new video subtitle.
@param i_spu: new video subtitle to select
@return: 0 on success, -1 if out of range
"""
return libvlc_video_set_spu(self, i_spu)
if hasattr(dll, 'libvlc_video_set_subtitle_file'):
def video_set_subtitle_file(self, psz_subtitle):
"""Set new video subtitle file.
@param psz_subtitle: new video subtitle file
@return: the success status (boolean)
"""
return libvlc_video_set_subtitle_file(self, psz_subtitle)
if hasattr(dll, 'libvlc_video_get_crop_geometry'):
def video_get_crop_geometry(self):
"""Get current crop filter geometry.
@return: the crop filter geometry or NULL if unset
"""
return libvlc_video_get_crop_geometry(self)
if hasattr(dll, 'libvlc_video_set_crop_geometry'):
def video_set_crop_geometry(self, psz_geometry):
"""Set new crop filter geometry.
@param psz_geometry: new crop filter geometry (NULL to unset)
"""
return libvlc_video_set_crop_geometry(self, psz_geometry)
if hasattr(dll, 'libvlc_video_get_teletext'):
def video_get_teletext(self):
"""Get current teletext page requested.
@return: the current teletext page requested.
"""
return libvlc_video_get_teletext(self)
if hasattr(dll, 'libvlc_video_set_teletext'):
def video_set_teletext(self, i_page):
"""Set new teletext page to retrieve.
@param i_page: teletex page number requested
"""
return libvlc_video_set_teletext(self, i_page)
if hasattr(dll, 'libvlc_toggle_teletext'):
def toggle_teletext(self):
"""Toggle teletext transparent status on video output.
"""
return libvlc_toggle_teletext(self)
if hasattr(dll, 'libvlc_video_get_track_count'):
def video_get_track_count(self):
"""Get number of available video tracks.
@return: the number of available video tracks (int)
"""
return libvlc_video_get_track_count(self)
if hasattr(dll, 'libvlc_video_get_track'):
def video_get_track(self):
"""Get current video track.
@return: the video track (int) or -1 if none
"""
return libvlc_video_get_track(self)
if hasattr(dll, 'libvlc_video_set_track'):
def video_set_track(self, i_track):
"""Set video track.
@param i_track: the track (int)
@return: 0 on success, -1 if out of range
"""
return libvlc_video_set_track(self, i_track)
if hasattr(dll, 'libvlc_video_take_snapshot'):
def video_take_snapshot(self, num, psz_filepath, i_width, i_height):
"""Take a snapshot of the current video window.
If i_width AND i_height is 0, original size is used.
If i_width XOR i_height is 0, original aspect-ratio is preserved.
@param num: number of video output (typically 0 for the first/only one)
@param psz_filepath: the path where to save the screenshot to
@param i_width: the snapshot's width
@param i_height: the snapshot's height
@return: 0 on success, -1 if the video was not found
"""
return libvlc_video_take_snapshot(self, num, psz_filepath, i_width, i_height)
if hasattr(dll, 'libvlc_video_set_deinterlace'):
def video_set_deinterlace(self, psz_mode):
"""Enable or disable deinterlace filter
@param psz_mode: type of deinterlace filter, NULL to disable
"""
return libvlc_video_set_deinterlace(self, psz_mode)
if hasattr(dll, 'libvlc_video_get_marquee_int'):
def video_get_marquee_int(self, option):
"""Get an integer marquee option value
@param option: marq option to get See libvlc_video_marquee_int_option_t
"""
return libvlc_video_get_marquee_int(self, option)
if hasattr(dll, 'libvlc_video_get_marquee_string'):
def video_get_marquee_string(self, option):
"""Get a string marquee option value
@param option: marq option to get See libvlc_video_marquee_string_option_t
"""
return libvlc_video_get_marquee_string(self, option)
if hasattr(dll, 'libvlc_video_set_marquee_int'):
def video_set_marquee_int(self, option, i_val):
"""Enable, disable or set an integer marquee option
Setting libvlc_marquee_Enable has the side effect of enabling (arg !0)
or disabling (arg 0) the marq filter.
@param option: marq option to set See libvlc_video_marquee_int_option_t
@param i_val: marq option value
"""
return libvlc_video_set_marquee_int(self, option, i_val)
if hasattr(dll, 'libvlc_video_set_marquee_string'):
def video_set_marquee_string(self, option, psz_text):
"""Set a marquee string option
@param option: marq option to set See libvlc_video_marquee_string_option_t
@param psz_text: marq option value
"""
return libvlc_video_set_marquee_string(self, option, psz_text)
if hasattr(dll, 'libvlc_video_get_logo_int'):
def video_get_logo_int(self, option):
"""Get integer logo option.
@param option: logo option to get, values of libvlc_video_logo_option_t
"""
return libvlc_video_get_logo_int(self, option)
if hasattr(dll, 'libvlc_video_set_logo_int'):
def video_set_logo_int(self, option, value):
"""Set logo option as integer. Options that take a different type value
are ignored.
Passing libvlc_logo_enable as option value has the side effect of
starting (arg !0) or stopping (arg 0) the logo filter.
@param option: logo option to set, values of libvlc_video_logo_option_t
@param value: logo option value
"""
return libvlc_video_set_logo_int(self, option, value)
if hasattr(dll, 'libvlc_video_set_logo_string'):
def video_set_logo_string(self, option, psz_value):
"""Set logo option as string. Options that take a different type value
are ignored.
@param option: logo option to set, values of libvlc_video_logo_option_t
@param psz_value: logo option value
"""
return libvlc_video_set_logo_string(self, option, psz_value)
if hasattr(dll, 'libvlc_video_get_adjust_int'):
def video_get_adjust_int(self, option):
"""Get integer adjust option.
@param option: adjust option to get, values of libvlc_video_adjust_option_t
"""
return libvlc_video_get_adjust_int(self, option)
if hasattr(dll, 'libvlc_video_set_adjust_int'):
def video_set_adjust_int(self, option, value):
"""Set adjust option as integer. Options that take a different type value
are ignored.
Passing libvlc_adjust_enable as option value has the side effect of
starting (arg !0) or stopping (arg 0) the adjust filter.
@param option: adust option to set, values of libvlc_video_adjust_option_t
@param value: adjust option value
"""
return libvlc_video_set_adjust_int(self, option, value)
if hasattr(dll, 'libvlc_video_get_adjust_float'):
def video_get_adjust_float(self, option):
"""Get float adjust option.
@param option: adjust option to get, values of libvlc_video_adjust_option_t
"""
return libvlc_video_get_adjust_float(self, option)
if hasattr(dll, 'libvlc_video_set_adjust_float'):
def video_set_adjust_float(self, option, value):
"""Set adjust option as float. Options that take a different type value
are ignored.
@param option: adust option to set, values of libvlc_video_adjust_option_t
@param value: adjust option value
"""
return libvlc_video_set_adjust_float(self, option, value)
if hasattr(dll, 'libvlc_audio_output_set'):
def audio_output_set(self, psz_name):
"""Set the audio output.
Change will be applied after stop and play.
@param psz_name: name of audio output,
@return: true if function succeded
"""
return libvlc_audio_output_set(self, psz_name)
if hasattr(dll, 'libvlc_audio_output_device_set'):
def audio_output_device_set(self, psz_audio_output, psz_device_id):
"""Set audio output device. Changes are only effective after stop and play.
@param psz_audio_output: - name of audio output, See libvlc_audio_output_t
@param psz_device_id: device
"""
return libvlc_audio_output_device_set(self, psz_audio_output, psz_device_id)
if hasattr(dll, 'libvlc_audio_output_get_device_type'):
def audio_output_get_device_type(self):
"""Get current audio device type. Device type describes something like
character of output sound - stereo sound, 2.1, 5.1 etc
@return: the audio devices type See libvlc_audio_output_device_types_t
"""
return libvlc_audio_output_get_device_type(self)
if hasattr(dll, 'libvlc_audio_output_set_device_type'):
def audio_output_set_device_type(self, device_type):
"""Set current audio device type.
@param device_type: the audio device type,
"""
return libvlc_audio_output_set_device_type(self, device_type)
if hasattr(dll, 'libvlc_audio_toggle_mute'):
def audio_toggle_mute(self):
"""Toggle mute status.
"""
return libvlc_audio_toggle_mute(self)
if hasattr(dll, 'libvlc_audio_get_mute'):
def audio_get_mute(self):
"""Get current mute status.
@return: the mute status (boolean)
"""
return libvlc_audio_get_mute(self)
if hasattr(dll, 'libvlc_audio_set_mute'):
def audio_set_mute(self, status):
"""Set mute status.
@param status: If status is true then mute, otherwise unmute
"""
return libvlc_audio_set_mute(self, status)
if hasattr(dll, 'libvlc_audio_get_volume'):
def audio_get_volume(self):
"""Get current audio level.
@return: the audio level (int)
"""
return libvlc_audio_get_volume(self)
if hasattr(dll, 'libvlc_audio_set_volume'):
def audio_set_volume(self, i_volume):
"""Set current audio level.
@param i_volume: the volume (int)
@return: 0 if the volume was set, -1 if it was out of range
"""
return libvlc_audio_set_volume(self, i_volume)
if hasattr(dll, 'libvlc_audio_get_track_count'):
def audio_get_track_count(self):
"""Get number of available audio tracks.
@return: the number of available audio tracks (int), or -1 if unavailable
"""
return libvlc_audio_get_track_count(self)
if hasattr(dll, 'libvlc_audio_get_track'):
def audio_get_track(self):
"""Get current audio track.
@return: the audio track (int), or -1 if none.
"""
return libvlc_audio_get_track(self)
if hasattr(dll, 'libvlc_audio_set_track'):
def audio_set_track(self, i_track):
"""Set current audio track.
@param i_track: the track (int)
@return: 0 on success, -1 on error
"""
return libvlc_audio_set_track(self, i_track)
if hasattr(dll, 'libvlc_audio_get_channel'):
def audio_get_channel(self):
"""Get current audio channel.
@return: the audio channel See libvlc_audio_output_channel_t
"""
return libvlc_audio_get_channel(self)
if hasattr(dll, 'libvlc_audio_set_channel'):
def audio_set_channel(self, channel):
"""Set current audio channel.
@param channel: the audio channel, See libvlc_audio_output_channel_t
@return: 0 on success, -1 on error
"""
return libvlc_audio_set_channel(self, channel)
if hasattr(dll, 'libvlc_audio_get_delay'):
def audio_get_delay(self):
"""Get current audio delay.
@return: the audio delay (microseconds)
"""
return libvlc_audio_get_delay(self)
if hasattr(dll, 'libvlc_audio_set_delay'):
def audio_set_delay(self, i_delay):
"""Set current audio delay. The audio delay will be reset to zero each time the media changes.
@param i_delay: the audio delay (microseconds)
@return: 0 on success, -1 on error
"""
return libvlc_audio_set_delay(self, i_delay)
if hasattr(dll, 'libvlc_errmsg'):
prototype=ctypes.CFUNCTYPE(ctypes.c_char_p)
paramflags= tuple()
libvlc_errmsg = prototype( ("libvlc_errmsg", dll), paramflags )
libvlc_errmsg.__doc__ = """A human-readable error message for the last LibVLC error in the calling
thread. The resulting string is valid until another error occurs (at least
until the next LibVLC call).
@warning
This will be NULL if there was no error.
"""
if hasattr(dll, 'libvlc_clearerr'):
prototype=ctypes.CFUNCTYPE(None)
paramflags= tuple()
libvlc_clearerr = prototype( ("libvlc_clearerr", dll), paramflags )
libvlc_clearerr.__doc__ = """Clears the LibVLC error status for the current thread. This is optional.
By default, the error status is automatically overriden when a new error
occurs, and destroyed when the thread exits.
"""
if hasattr(dll, 'libvlc_new'):
prototype=ctypes.CFUNCTYPE(Instance, ctypes.c_int, ListPOINTER(ctypes.c_char_p))
paramflags=(1,), (1,)
libvlc_new = prototype( ("libvlc_new", dll), paramflags )
libvlc_new.__doc__ = """Create and initialize a libvlc instance.
\param argc the number of arguments
\param argv command-line-type arguments
\return the libvlc instance or NULL in case of error
"""
if hasattr(dll, 'libvlc_release'):
prototype=ctypes.CFUNCTYPE(None, Instance)
paramflags=( (1, ), )
libvlc_release = prototype( ("libvlc_release", dll), paramflags )
libvlc_release.__doc__ = """Decrement the reference count of a libvlc instance, and destroy it
if it reaches zero.
\param p_instance the instance to destroy
"""
if hasattr(dll, 'libvlc_retain'):
prototype=ctypes.CFUNCTYPE(None, Instance)
paramflags=( (1, ), )
libvlc_retain = prototype( ("libvlc_retain", dll), paramflags )
libvlc_retain.__doc__ = """Increments the reference count of a libvlc instance.
The initial reference count is 1 after libvlc_new() returns.
\param p_instance the instance to reference
"""
if hasattr(dll, 'libvlc_add_intf'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, Instance, ctypes.c_char_p)
paramflags=(1,), (1,)
libvlc_add_intf = prototype( ("libvlc_add_intf", dll), paramflags )
libvlc_add_intf.__doc__ = """Try to start a user interface for the libvlc instance.
\param p_instance the instance
\param name interface name, or NULL for default
\return 0 on success, -1 on error.
"""
if hasattr(dll, 'libvlc_wait'):
prototype=ctypes.CFUNCTYPE(None, Instance)
paramflags=( (1, ), )
libvlc_wait = prototype( ("libvlc_wait", dll), paramflags )
libvlc_wait.__doc__ = """Waits until an interface causes the instance to exit.
You should start at least one interface first, using libvlc_add_intf().
\param p_instance the instance
"""
if hasattr(dll, 'libvlc_set_user_agent'):
prototype=ctypes.CFUNCTYPE(None, Instance, ctypes.c_char_p, ctypes.c_char_p)
paramflags=(1,), (1,), (1,)
libvlc_set_user_agent = prototype( ("libvlc_set_user_agent", dll), paramflags )
libvlc_set_user_agent.__doc__ = """Sets the application name. LibVLC passes this as the user agent string
when a protocol requires it.
\param p_instance LibVLC instance
\param name human-readable application name, e.g. "FooBar player 1.2.3"
\param http HTTP User Agent, e.g. "FooBar/1.2.3 Python/2.6.0"
\version LibVLC 1.1.1 or later
"""
if hasattr(dll, 'libvlc_get_version'):
prototype=ctypes.CFUNCTYPE(ctypes.c_char_p)
paramflags= tuple()
libvlc_get_version = prototype( ("libvlc_get_version", dll), paramflags )
libvlc_get_version.__doc__ = """Retrieve libvlc version.
Example: "1.1.0-git The Luggage"
\return a string containing the libvlc version
"""
if hasattr(dll, 'libvlc_get_compiler'):
prototype=ctypes.CFUNCTYPE(ctypes.c_char_p)
paramflags= tuple()
libvlc_get_compiler = prototype( ("libvlc_get_compiler", dll), paramflags )
libvlc_get_compiler.__doc__ = """Retrieve libvlc compiler version.
Example: "gcc version 4.2.3 (Ubuntu 4.2.3-2ubuntu6)"
\return a string containing the libvlc compiler version
"""
if hasattr(dll, 'libvlc_get_changeset'):
prototype=ctypes.CFUNCTYPE(ctypes.c_char_p)
paramflags= tuple()
libvlc_get_changeset = prototype( ("libvlc_get_changeset", dll), paramflags )
libvlc_get_changeset.__doc__ = """Retrieve libvlc changeset.
Example: "aa9bce0bc4"
\return a string containing the libvlc changeset
"""
if hasattr(dll, 'libvlc_event_attach'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, EventManager, ctypes.c_uint, ctypes.c_void_p, ctypes.c_void_p)
paramflags=(1,), (1,), (1,), (1,)
libvlc_event_attach = prototype( ("libvlc_event_attach", dll), paramflags )
libvlc_event_attach.__doc__ = """Register for an event notification.
\param p_event_manager the event manager to which you want to attach to.
Generally it is obtained by vlc_my_object_event_manager() where
my_object is the object you want to listen to.
\param i_event_type the desired event to which we want to listen
\param f_callback the function to call when i_event_type occurs
\param user_data user provided data to carry with the event
\return 0 on success, ENOMEM on error
"""
if hasattr(dll, 'libvlc_event_detach'):
prototype=ctypes.CFUNCTYPE(None, EventManager, ctypes.c_uint, ctypes.c_void_p, ctypes.c_void_p)
paramflags=(1,), (1,), (1,), (1,)
libvlc_event_detach = prototype( ("libvlc_event_detach", dll), paramflags )
libvlc_event_detach.__doc__ = """Unregister an event notification.
\param p_event_manager the event manager
\param i_event_type the desired event to which we want to unregister
\param f_callback the function to call when i_event_type occurs
\param p_user_data user provided data to carry with the event
"""
if hasattr(dll, 'libvlc_event_type_name'):
prototype=ctypes.CFUNCTYPE(ctypes.c_char_p, ctypes.c_uint)
paramflags=( (1, ), )
libvlc_event_type_name = prototype( ("libvlc_event_type_name", dll), paramflags )
libvlc_event_type_name.__doc__ = """Get an event's type name.
\param event_type the desired event
"""
if hasattr(dll, 'libvlc_get_log_verbosity'):
prototype=ctypes.CFUNCTYPE(ctypes.c_uint, Instance)
paramflags=( (1, ), )
libvlc_get_log_verbosity = prototype( ("libvlc_get_log_verbosity", dll), paramflags )
libvlc_get_log_verbosity.__doc__ = """Return the VLC messaging verbosity level.
\param p_instance libvlc instance
\return verbosity level for messages
"""
if hasattr(dll, 'libvlc_set_log_verbosity'):
prototype=ctypes.CFUNCTYPE(None, Instance, ctypes.c_uint)
paramflags=(1,), (1,)
libvlc_set_log_verbosity = prototype( ("libvlc_set_log_verbosity", dll), paramflags )
libvlc_set_log_verbosity.__doc__ = """Set the VLC messaging verbosity level.
\param p_instance libvlc log instance
\param level log level
"""
if hasattr(dll, 'libvlc_log_open'):
prototype=ctypes.CFUNCTYPE(Log, Instance)
paramflags=( (1, ), )
libvlc_log_open = prototype( ("libvlc_log_open", dll), paramflags )
libvlc_log_open.__doc__ = """Open a VLC message log instance.
\param p_instance libvlc instance
\return log message instance or NULL on error
"""
if hasattr(dll, 'libvlc_log_close'):
prototype=ctypes.CFUNCTYPE(None, Log)
paramflags=( (1, ), )
libvlc_log_close = prototype( ("libvlc_log_close", dll), paramflags )
libvlc_log_close.__doc__ = """Close a VLC message log instance.
\param p_log libvlc log instance or NULL
"""
if hasattr(dll, 'libvlc_log_count'):
prototype=ctypes.CFUNCTYPE(ctypes.c_uint, Log)
paramflags=( (1, ), )
libvlc_log_count = prototype( ("libvlc_log_count", dll), paramflags )
libvlc_log_count.__doc__ = """Returns the number of messages in a log instance.
\param p_log libvlc log instance or NULL
\return number of log messages, 0 if p_log is NULL
"""
if hasattr(dll, 'libvlc_log_clear'):
prototype=ctypes.CFUNCTYPE(None, Log)
paramflags=( (1, ), )
libvlc_log_clear = prototype( ("libvlc_log_clear", dll), paramflags )
libvlc_log_clear.__doc__ = """Clear a log instance.
All messages in the log are removed. The log should be cleared on a
regular basis to avoid clogging.
\param p_log libvlc log instance or NULL
"""
if hasattr(dll, 'libvlc_log_get_iterator'):
prototype=ctypes.CFUNCTYPE(LogIterator, Log)
paramflags=( (1, ), )
libvlc_log_get_iterator = prototype( ("libvlc_log_get_iterator", dll), paramflags )
libvlc_log_get_iterator.__doc__ = """Allocate and returns a new iterator to messages in log.
\param p_log libvlc log instance
\return log iterator object or NULL on error
"""
if hasattr(dll, 'libvlc_log_iterator_free'):
prototype=ctypes.CFUNCTYPE(None, LogIterator)
paramflags=( (1, ), )
libvlc_log_iterator_free = prototype( ("libvlc_log_iterator_free", dll), paramflags )
libvlc_log_iterator_free.__doc__ = """Release a previoulsy allocated iterator.
\param p_iter libvlc log iterator or NULL
"""
if hasattr(dll, 'libvlc_log_iterator_has_next'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, LogIterator)
paramflags=( (1, ), )
libvlc_log_iterator_has_next = prototype( ("libvlc_log_iterator_has_next", dll), paramflags )
libvlc_log_iterator_has_next.__doc__ = """Return whether log iterator has more messages.
\param p_iter libvlc log iterator or NULL
\return true if iterator has more message objects, else false
"""
if hasattr(dll, 'libvlc_log_iterator_next'):
prototype=ctypes.CFUNCTYPE(ctypes.POINTER(LogMessage), LogIterator, ctypes.POINTER(LogMessage))
paramflags=(1,), (1,)
libvlc_log_iterator_next = prototype( ("libvlc_log_iterator_next", dll), paramflags )
libvlc_log_iterator_next.__doc__ = """Return the next log message.
The message contents must not be freed
\param p_iter libvlc log iterator or NULL
\param p_buffer log buffer
\return log message object or NULL if none left
"""
if hasattr(dll, 'libvlc_media_new_location'):
prototype=ctypes.CFUNCTYPE(Media, Instance, ctypes.c_char_p)
paramflags=(1,), (1,)
libvlc_media_new_location = prototype( ("libvlc_media_new_location", dll), paramflags )
libvlc_media_new_location.__doc__ = """Create a media with a certain given media resource location.
\see libvlc_media_release
\param p_instance the instance
\param psz_mrl the MRL to read
\return the newly created media or NULL on error
"""
if hasattr(dll, 'libvlc_media_new_path'):
prototype=ctypes.CFUNCTYPE(Media, Instance, ctypes.c_char_p)
paramflags=(1,), (1,)
libvlc_media_new_path = prototype( ("libvlc_media_new_path", dll), paramflags )
libvlc_media_new_path.__doc__ = """Create a media with a certain file path.
\see libvlc_media_release
\param p_instance the instance
\param path local filesystem path
\return the newly created media or NULL on error
"""
if hasattr(dll, 'libvlc_media_new_as_node'):
prototype=ctypes.CFUNCTYPE(Media, Instance, ctypes.c_char_p)
paramflags=(1,), (1,)
libvlc_media_new_as_node = prototype( ("libvlc_media_new_as_node", dll), paramflags )
libvlc_media_new_as_node.__doc__ = """Create a media as an empty node with a given name.
\see libvlc_media_release
\param p_instance the instance
\param psz_name the name of the node
\return the new empty media or NULL on error
"""
if hasattr(dll, 'libvlc_media_add_option'):
prototype=ctypes.CFUNCTYPE(None, Media, ctypes.c_char_p)
paramflags=(1,), (1,)
libvlc_media_add_option = prototype( ("libvlc_media_add_option", dll), paramflags )
libvlc_media_add_option.__doc__ = """Add an option to the media.
This option will be used to determine how the media_player will
read the media. This allows to use VLC's advanced
reading/streaming options on a per-media basis.
The options are detailed in vlc --long-help, for instance "--sout-all"
\param p_md the media descriptor
\param ppsz_options the options (as a string)
"""
if hasattr(dll, 'libvlc_media_add_option_flag'):
prototype=ctypes.CFUNCTYPE(None, Media, ctypes.c_char_p, ctypes.c_uint)
paramflags=(1,), (1,), (1,)
libvlc_media_add_option_flag = prototype( ("libvlc_media_add_option_flag", dll), paramflags )
libvlc_media_add_option_flag.__doc__ = """Add an option to the media with configurable flags.
This option will be used to determine how the media_player will
read the media. This allows to use VLC's advanced
reading/streaming options on a per-media basis.
The options are detailed in vlc --long-help, for instance "--sout-all"
\param p_md the media descriptor
\param ppsz_options the options (as a string)
\param i_flags the flags for this option
"""
if hasattr(dll, 'libvlc_media_retain'):
prototype=ctypes.CFUNCTYPE(None, Media)
paramflags=( (1, ), )
libvlc_media_retain = prototype( ("libvlc_media_retain", dll), paramflags )
libvlc_media_retain.__doc__ = """Retain a reference to a media descriptor object (libvlc_media_t). Use
libvlc_media_release() to decrement the reference count of a
media descriptor object.
\param p_md the media descriptor
"""
if hasattr(dll, 'libvlc_media_release'):
prototype=ctypes.CFUNCTYPE(None, Media)
paramflags=( (1, ), )
libvlc_media_release = prototype( ("libvlc_media_release", dll), paramflags )
libvlc_media_release.__doc__ = """Decrement the reference count of a media descriptor object. If the
reference count is 0, then libvlc_media_release() will release the
media descriptor object. It will send out an libvlc_MediaFreed event
to all listeners. If the media descriptor object has been released it
should not be used again.
\param p_md the media descriptor
"""
if hasattr(dll, 'libvlc_media_get_mrl'):
prototype=ctypes.CFUNCTYPE(ctypes.c_char_p, Media)
paramflags=( (1, ), )
libvlc_media_get_mrl = prototype( ("libvlc_media_get_mrl", dll), paramflags )
libvlc_media_get_mrl.__doc__ = """Get the media resource locator (mrl) from a media descriptor object
\param p_md a media descriptor object
\return string with mrl of media descriptor object
"""
if hasattr(dll, 'libvlc_media_duplicate'):
prototype=ctypes.CFUNCTYPE(Media, Media)
paramflags=( (1, ), )
libvlc_media_duplicate = prototype( ("libvlc_media_duplicate", dll), paramflags )
libvlc_media_duplicate.__doc__ = """Duplicate a media descriptor object.
\param p_md a media descriptor object.
"""
if hasattr(dll, 'libvlc_media_get_meta'):
prototype=ctypes.CFUNCTYPE(ctypes.c_char_p, Media, Meta)
paramflags=(1,), (1,)
libvlc_media_get_meta = prototype( ("libvlc_media_get_meta", dll), paramflags )
libvlc_media_get_meta.__doc__ = """Read the meta of the media.
If the media has not yet been parsed this will return NULL.
This methods automatically calls libvlc_media_parse_async(), so after calling
it you may receive a libvlc_MediaMetaChanged event. If you prefer a synchronous
version ensure that you call libvlc_media_parse() before get_meta().
\see libvlc_media_parse
\see libvlc_media_parse_async
\see libvlc_MediaMetaChanged
\param p_md the media descriptor
\param e_meta the meta to read
\return the media's meta
"""
if hasattr(dll, 'libvlc_media_set_meta'):
prototype=ctypes.CFUNCTYPE(None, Media, Meta, ctypes.c_char_p)
paramflags=(1,), (1,), (1,)
libvlc_media_set_meta = prototype( ("libvlc_media_set_meta", dll), paramflags )
libvlc_media_set_meta.__doc__ = """Set the meta of the media (this function will not save the meta, call
libvlc_media_save_meta in order to save the meta)
\param p_md the media descriptor
\param e_meta the meta to write
\param psz_value the media's meta
"""
if hasattr(dll, 'libvlc_media_save_meta'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, Media)
paramflags=( (1, ), )
libvlc_media_save_meta = prototype( ("libvlc_media_save_meta", dll), paramflags )
libvlc_media_save_meta.__doc__ = """Save the meta previously set
\param p_md the media desriptor
\return true if the write operation was successfull
"""
if hasattr(dll, 'libvlc_media_get_state'):
prototype=ctypes.CFUNCTYPE(State, Media)
paramflags=( (1, ), )
libvlc_media_get_state = prototype( ("libvlc_media_get_state", dll), paramflags )
libvlc_media_get_state.__doc__ = """Get current state of media descriptor object. Possible media states
are defined in libvlc_structures.c ( libvlc_NothingSpecial=0,
libvlc_Opening, libvlc_Buffering, libvlc_Playing, libvlc_Paused,
libvlc_Stopped, libvlc_Ended,
libvlc_Error).
\see libvlc_state_t
\param p_md a media descriptor object
\return state of media descriptor object
"""
if hasattr(dll, 'libvlc_media_get_stats'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, Media, ctypes.POINTER(MediaStats))
paramflags=(1,), (1,)
libvlc_media_get_stats = prototype( ("libvlc_media_get_stats", dll), paramflags )
libvlc_media_get_stats.__doc__ = """Get the current statistics about the media
\param p_md: media descriptor object
\param p_stats: structure that contain the statistics about the media
(this structure must be allocated by the caller)
\return true if the statistics are available, false otherwise
"""
if hasattr(dll, 'libvlc_media_subitems'):
prototype=ctypes.CFUNCTYPE(MediaList, Media)
paramflags=( (1, ), )
libvlc_media_subitems = prototype( ("libvlc_media_subitems", dll), paramflags )
libvlc_media_subitems.__doc__ = """Get subitems of media descriptor object. This will increment
the reference count of supplied media descriptor object. Use
libvlc_media_list_release() to decrement the reference counting.
\param p_md media descriptor object
\return list of media descriptor subitems or NULL
and this is here for convenience */
"""
if hasattr(dll, 'libvlc_media_event_manager'):
prototype=ctypes.CFUNCTYPE(EventManager, Media)
paramflags=( (1, ), )
libvlc_media_event_manager = prototype( ("libvlc_media_event_manager", dll), paramflags )
libvlc_media_event_manager.__doc__ = """Get event manager from media descriptor object.
NOTE: this function doesn't increment reference counting.
\param p_md a media descriptor object
\return event manager object
"""
if hasattr(dll, 'libvlc_media_get_duration'):
prototype=ctypes.CFUNCTYPE(ctypes.c_longlong, Media)
paramflags=( (1, ), )
libvlc_media_get_duration = prototype( ("libvlc_media_get_duration", dll), paramflags )
libvlc_media_get_duration.__doc__ = """Get duration (in ms) of media descriptor object item.
\param p_md media descriptor object
\return duration of media item or -1 on error
"""
if hasattr(dll, 'libvlc_media_parse'):
prototype=ctypes.CFUNCTYPE(None, Media)
paramflags=( (1, ), )
libvlc_media_parse = prototype( ("libvlc_media_parse", dll), paramflags )
libvlc_media_parse.__doc__ = """Parse a media.
This fetches (local) meta data and tracks information.
The method is synchronous.
\see libvlc_media_parse_async
\see libvlc_media_get_meta
\see libvlc_media_get_tracks_info
\param p_md media descriptor object
"""
if hasattr(dll, 'libvlc_media_parse_async'):
prototype=ctypes.CFUNCTYPE(None, Media)
paramflags=( (1, ), )
libvlc_media_parse_async = prototype( ("libvlc_media_parse_async", dll), paramflags )
libvlc_media_parse_async.__doc__ = """Parse a media.
This fetches (local) meta data and tracks information.
The method is the asynchronous of libvlc_media_parse().
To track when this is over you can listen to libvlc_MediaParsedChanged
event. However if the media was already parsed you will not receive this
event.
\see libvlc_media_parse
\see libvlc_MediaParsedChanged
\see libvlc_media_get_meta
\see libvlc_media_get_tracks_info
\param p_md media descriptor object
"""
if hasattr(dll, 'libvlc_media_is_parsed'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, Media)
paramflags=( (1, ), )
libvlc_media_is_parsed = prototype( ("libvlc_media_is_parsed", dll), paramflags )
libvlc_media_is_parsed.__doc__ = """Get Parsed status for media descriptor object.
\see libvlc_MediaParsedChanged
\param p_md media descriptor object
\return true if media object has been parsed otherwise it returns false
"""
if hasattr(dll, 'libvlc_media_set_user_data'):
prototype=ctypes.CFUNCTYPE(None, Media, ctypes.c_void_p)
paramflags=(1,), (1,)
libvlc_media_set_user_data = prototype( ("libvlc_media_set_user_data", dll), paramflags )
libvlc_media_set_user_data.__doc__ = """Sets media descriptor's user_data. user_data is specialized data
accessed by the host application, VLC.framework uses it as a pointer to
an native object that references a libvlc_media_t pointer
\param p_md media descriptor object
\param p_new_user_data pointer to user data
"""
if hasattr(dll, 'libvlc_media_get_user_data'):
prototype=ctypes.CFUNCTYPE(ctypes.c_void_p, Media)
paramflags=( (1, ), )
libvlc_media_get_user_data = prototype( ("libvlc_media_get_user_data", dll), paramflags )
libvlc_media_get_user_data.__doc__ = """Get media descriptor's user_data. user_data is specialized data
accessed by the host application, VLC.framework uses it as a pointer to
an native object that references a libvlc_media_t pointer
\param p_md media descriptor object
"""
if hasattr(dll, 'libvlc_media_get_tracks_info'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, Media, ctypes.POINTER(ctypes.POINTER(MediaTrackInfo)))
paramflags=(1,), (1,)
libvlc_media_get_tracks_info = prototype( ("libvlc_media_get_tracks_info", dll), paramflags )
libvlc_media_get_tracks_info.__doc__ = """Get media descriptor's elementary streams description
Note, you need to play the media _one_ time with --sout="#description"
Not doing this will result in an empty array, and doing it more than once
will duplicate the entries in the array each time. Something like this:
@begincode
libvlc_media_player_t *player = libvlc_media_player_new_from_media(media);
libvlc_media_add_option_flag(media, "sout=\"#description\"");
libvlc_media_player_play(player);
// ... wait until playing
libvlc_media_player_release(player);
@endcode
This is very likely to change in next release, and be done at the parsing
phase.
\param p_md media descriptor object
\param tracks address to store an allocated array of Elementary Streams
descriptions (must be freed by the caller)
return the number of Elementary Streams
"""
if hasattr(dll, 'libvlc_media_discoverer_new_from_name'):
prototype=ctypes.CFUNCTYPE(MediaDiscoverer, Instance, ctypes.c_char_p)
paramflags=(1,), (1,)
libvlc_media_discoverer_new_from_name = prototype( ("libvlc_media_discoverer_new_from_name", dll), paramflags )
libvlc_media_discoverer_new_from_name.__doc__ = """Discover media service by name.
\param p_inst libvlc instance
\param psz_name service name
\return media discover object or NULL in case of error
"""
if hasattr(dll, 'libvlc_media_discoverer_release'):
prototype=ctypes.CFUNCTYPE(None, MediaDiscoverer)
paramflags=( (1, ), )
libvlc_media_discoverer_release = prototype( ("libvlc_media_discoverer_release", dll), paramflags )
libvlc_media_discoverer_release.__doc__ = """Release media discover object. If the reference count reaches 0, then
the object will be released.
\param p_mdis media service discover object
"""
if hasattr(dll, 'libvlc_media_discoverer_localized_name'):
prototype=ctypes.CFUNCTYPE(ctypes.c_char_p, MediaDiscoverer)
paramflags=( (1, ), )
libvlc_media_discoverer_localized_name = prototype( ("libvlc_media_discoverer_localized_name", dll), paramflags )
libvlc_media_discoverer_localized_name.__doc__ = """Get media service discover object its localized name.
\param p_mdis media discover object
\return localized name
"""
if hasattr(dll, 'libvlc_media_discoverer_media_list'):
prototype=ctypes.CFUNCTYPE(MediaList, MediaDiscoverer)
paramflags=( (1, ), )
libvlc_media_discoverer_media_list = prototype( ("libvlc_media_discoverer_media_list", dll), paramflags )
libvlc_media_discoverer_media_list.__doc__ = """Get media service discover media list.
\param p_mdis media service discover object
\return list of media items
"""
if hasattr(dll, 'libvlc_media_discoverer_event_manager'):
prototype=ctypes.CFUNCTYPE(EventManager, MediaDiscoverer)
paramflags=( (1, ), )
libvlc_media_discoverer_event_manager = prototype( ("libvlc_media_discoverer_event_manager", dll), paramflags )
libvlc_media_discoverer_event_manager.__doc__ = """Get event manager from media service discover object.
\param p_mdis media service discover object
\return event manager object.
"""
if hasattr(dll, 'libvlc_media_discoverer_is_running'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, MediaDiscoverer)
paramflags=( (1, ), )
libvlc_media_discoverer_is_running = prototype( ("libvlc_media_discoverer_is_running", dll), paramflags )
libvlc_media_discoverer_is_running.__doc__ = """Query if media service discover object is running.
\param p_mdis media service discover object
\return true if running, false if not
"""
if hasattr(dll, 'libvlc_media_library_new'):
prototype=ctypes.CFUNCTYPE(MediaLibrary, Instance)
paramflags=( (1, ), )
libvlc_media_library_new = prototype( ("libvlc_media_library_new", dll), paramflags )
libvlc_media_library_new.__doc__ = """Create an new Media Library object
\param p_instance the libvlc instance
\return a new object or NULL on error
"""
if hasattr(dll, 'libvlc_media_library_release'):
prototype=ctypes.CFUNCTYPE(None, MediaLibrary)
paramflags=( (1, ), )
libvlc_media_library_release = prototype( ("libvlc_media_library_release", dll), paramflags )
libvlc_media_library_release.__doc__ = """Release media library object. This functions decrements the
reference count of the media library object. If it reaches 0,
then the object will be released.
\param p_mlib media library object
"""
if hasattr(dll, 'libvlc_media_library_retain'):
prototype=ctypes.CFUNCTYPE(None, MediaLibrary)
paramflags=( (1, ), )
libvlc_media_library_retain = prototype( ("libvlc_media_library_retain", dll), paramflags )
libvlc_media_library_retain.__doc__ = """Retain a reference to a media library object. This function will
increment the reference counting for this object. Use
libvlc_media_library_release() to decrement the reference count.
\param p_mlib media library object
"""
if hasattr(dll, 'libvlc_media_library_load'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, MediaLibrary)
paramflags=( (1, ), )
libvlc_media_library_load = prototype( ("libvlc_media_library_load", dll), paramflags )
libvlc_media_library_load.__doc__ = """Load media library.
\param p_mlib media library object
\return 0 on success, -1 on error
"""
if hasattr(dll, 'libvlc_media_library_media_list'):
prototype=ctypes.CFUNCTYPE(MediaList, MediaLibrary)
paramflags=( (1, ), )
libvlc_media_library_media_list = prototype( ("libvlc_media_library_media_list", dll), paramflags )
libvlc_media_library_media_list.__doc__ = """Get media library subitems.
\param p_mlib media library object
\return media list subitems
"""
if hasattr(dll, 'libvlc_media_list_new'):
prototype=ctypes.CFUNCTYPE(MediaList, Instance)
paramflags=( (1, ), )
libvlc_media_list_new = prototype( ("libvlc_media_list_new", dll), paramflags )
libvlc_media_list_new.__doc__ = """Create an empty media list.
\param p_instance libvlc instance
\return empty media list, or NULL on error
"""
if hasattr(dll, 'libvlc_media_list_release'):
prototype=ctypes.CFUNCTYPE(None, MediaList)
paramflags=( (1, ), )
libvlc_media_list_release = prototype( ("libvlc_media_list_release", dll), paramflags )
libvlc_media_list_release.__doc__ = """Release media list created with libvlc_media_list_new().
\param p_ml a media list created with libvlc_media_list_new()
"""
if hasattr(dll, 'libvlc_media_list_retain'):
prototype=ctypes.CFUNCTYPE(None, MediaList)
paramflags=( (1, ), )
libvlc_media_list_retain = prototype( ("libvlc_media_list_retain", dll), paramflags )
libvlc_media_list_retain.__doc__ = """Retain reference to a media list
\param p_ml a media list created with libvlc_media_list_new()
"""
if hasattr(dll, 'libvlc_media_list_set_media'):
prototype=ctypes.CFUNCTYPE(None, MediaList, Media)
paramflags=(1,), (1,)
libvlc_media_list_set_media = prototype( ("libvlc_media_list_set_media", dll), paramflags )
libvlc_media_list_set_media.__doc__ = """Associate media instance with this media list instance.
If another media instance was present it will be released.
The libvlc_media_list_lock should NOT be held upon entering this function.
\param p_ml a media list instance
\param p_md media instance to add
"""
if hasattr(dll, 'libvlc_media_list_media'):
prototype=ctypes.CFUNCTYPE(Media, MediaList)
paramflags=( (1, ), )
libvlc_media_list_media = prototype( ("libvlc_media_list_media", dll), paramflags )
libvlc_media_list_media.__doc__ = """Get media instance from this media list instance. This action will increase
the refcount on the media instance.
The libvlc_media_list_lock should NOT be held upon entering this function.
\param p_ml a media list instance
\return media instance
"""
if hasattr(dll, 'libvlc_media_list_add_media'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, MediaList, Media)
paramflags=(1,), (1,)
libvlc_media_list_add_media = prototype( ("libvlc_media_list_add_media", dll), paramflags )
libvlc_media_list_add_media.__doc__ = """Add media instance to media list
The libvlc_media_list_lock should be held upon entering this function.
\param p_ml a media list instance
\param p_md a media instance
\return 0 on success, -1 if the media list is read-only
"""
if hasattr(dll, 'libvlc_media_list_insert_media'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, MediaList, Media, ctypes.c_int)
paramflags=(1,), (1,), (1,)
libvlc_media_list_insert_media = prototype( ("libvlc_media_list_insert_media", dll), paramflags )
libvlc_media_list_insert_media.__doc__ = """Insert media instance in media list on a position
The libvlc_media_list_lock should be held upon entering this function.
\param p_ml a media list instance
\param p_md a media instance
\param i_pos position in array where to insert
\return 0 on success, -1 if the media list si read-only
"""
if hasattr(dll, 'libvlc_media_list_remove_index'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, MediaList, ctypes.c_int)
paramflags=(1,), (1,)
libvlc_media_list_remove_index = prototype( ("libvlc_media_list_remove_index", dll), paramflags )
libvlc_media_list_remove_index.__doc__ = """Remove media instance from media list on a position
The libvlc_media_list_lock should be held upon entering this function.
\param p_ml a media list instance
\param i_pos position in array where to insert
\return 0 on success, -1 if the list is read-only or the item was not found
"""
if hasattr(dll, 'libvlc_media_list_count'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, MediaList)
paramflags=( (1, ), )
libvlc_media_list_count = prototype( ("libvlc_media_list_count", dll), paramflags )
libvlc_media_list_count.__doc__ = """Get count on media list items
The libvlc_media_list_lock should be held upon entering this function.
\param p_ml a media list instance
\return number of items in media list
"""
if hasattr(dll, 'libvlc_media_list_item_at_index'):
prototype=ctypes.CFUNCTYPE(Media, MediaList, ctypes.c_int)
paramflags=(1,), (1,)
libvlc_media_list_item_at_index = prototype( ("libvlc_media_list_item_at_index", dll), paramflags )
libvlc_media_list_item_at_index.__doc__ = """List media instance in media list at a position
The libvlc_media_list_lock should be held upon entering this function.
\param p_ml a media list instance
\param i_pos position in array where to insert
\return media instance at position i_pos, or NULL if not found.
In case of success, libvlc_media_retain() is called to increase the refcount
on the media.
"""
if hasattr(dll, 'libvlc_media_list_index_of_item'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, MediaList, Media)
paramflags=(1,), (1,)
libvlc_media_list_index_of_item = prototype( ("libvlc_media_list_index_of_item", dll), paramflags )
libvlc_media_list_index_of_item.__doc__ = """Find index position of List media instance in media list.
Warning: the function will return the first matched position.
The libvlc_media_list_lock should be held upon entering this function.
\param p_ml a media list instance
\param p_md media list instance
\return position of media instance
"""
if hasattr(dll, 'libvlc_media_list_is_readonly'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, MediaList)
paramflags=( (1, ), )
libvlc_media_list_is_readonly = prototype( ("libvlc_media_list_is_readonly", dll), paramflags )
libvlc_media_list_is_readonly.__doc__ = """This indicates if this media list is read-only from a user point of view
\param p_ml media list instance
\return 0 on readonly, 1 on readwrite
"""
if hasattr(dll, 'libvlc_media_list_lock'):
prototype=ctypes.CFUNCTYPE(None, MediaList)
paramflags=( (1, ), )
libvlc_media_list_lock = prototype( ("libvlc_media_list_lock", dll), paramflags )
libvlc_media_list_lock.__doc__ = """Get lock on media list items
\param p_ml a media list instance
"""
if hasattr(dll, 'libvlc_media_list_unlock'):
prototype=ctypes.CFUNCTYPE(None, MediaList)
paramflags=( (1, ), )
libvlc_media_list_unlock = prototype( ("libvlc_media_list_unlock", dll), paramflags )
libvlc_media_list_unlock.__doc__ = """Release lock on media list items
The libvlc_media_list_lock should be held upon entering this function.
\param p_ml a media list instance
"""
if hasattr(dll, 'libvlc_media_list_event_manager'):
prototype=ctypes.CFUNCTYPE(EventManager, MediaList)
paramflags=( (1, ), )
libvlc_media_list_event_manager = prototype( ("libvlc_media_list_event_manager", dll), paramflags )
libvlc_media_list_event_manager.__doc__ = """Get libvlc_event_manager from this media list instance.
The p_event_manager is immutable, so you don't have to hold the lock
\param p_ml a media list instance
\return libvlc_event_manager
"""
if hasattr(dll, 'libvlc_media_list_player_new'):
prototype=ctypes.CFUNCTYPE(MediaListPlayer, Instance)
paramflags=( (1, ), )
libvlc_media_list_player_new = prototype( ("libvlc_media_list_player_new", dll), paramflags )
libvlc_media_list_player_new.__doc__ = """Create new media_list_player.
\param p_instance libvlc instance
\return media list player instance or NULL on error
"""
if hasattr(dll, 'libvlc_media_list_player_release'):
prototype=ctypes.CFUNCTYPE(None, MediaListPlayer)
paramflags=( (1, ), )
libvlc_media_list_player_release = prototype( ("libvlc_media_list_player_release", dll), paramflags )
libvlc_media_list_player_release.__doc__ = """Release media_list_player.
\param p_mlp media list player instance
"""
if hasattr(dll, 'libvlc_media_list_player_event_manager'):
prototype=ctypes.CFUNCTYPE(EventManager, MediaListPlayer)
paramflags=( (1, ), )
libvlc_media_list_player_event_manager = prototype( ("libvlc_media_list_player_event_manager", dll), paramflags )
libvlc_media_list_player_event_manager.__doc__ = """Return the event manager of this media_list_player.
\param p_mlp media list player instance
\return the event manager
"""
if hasattr(dll, 'libvlc_media_list_player_set_media_player'):
prototype=ctypes.CFUNCTYPE(None, MediaListPlayer, MediaPlayer)
paramflags=(1,), (1,)
libvlc_media_list_player_set_media_player = prototype( ("libvlc_media_list_player_set_media_player", dll), paramflags )
libvlc_media_list_player_set_media_player.__doc__ = """Replace media player in media_list_player with this instance.
\param p_mlp media list player instance
\param p_mi media player instance
"""
if hasattr(dll, 'libvlc_media_list_player_set_media_list'):
prototype=ctypes.CFUNCTYPE(None, MediaListPlayer, MediaList)
paramflags=(1,), (1,)
libvlc_media_list_player_set_media_list = prototype( ("libvlc_media_list_player_set_media_list", dll), paramflags )
libvlc_media_list_player_set_media_list.__doc__ = """Set the media list associated with the player
\param p_mlp media list player instance
\param p_mlist list of media
"""
if hasattr(dll, 'libvlc_media_list_player_play'):
prototype=ctypes.CFUNCTYPE(None, MediaListPlayer)
paramflags=( (1, ), )
libvlc_media_list_player_play = prototype( ("libvlc_media_list_player_play", dll), paramflags )
libvlc_media_list_player_play.__doc__ = """Play media list
\param p_mlp media list player instance
"""
if hasattr(dll, 'libvlc_media_list_player_pause'):
prototype=ctypes.CFUNCTYPE(None, MediaListPlayer)
paramflags=( (1, ), )
libvlc_media_list_player_pause = prototype( ("libvlc_media_list_player_pause", dll), paramflags )
libvlc_media_list_player_pause.__doc__ = """Pause media list
\param p_mlp media list player instance
"""
if hasattr(dll, 'libvlc_media_list_player_is_playing'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, MediaListPlayer)
paramflags=( (1, ), )
libvlc_media_list_player_is_playing = prototype( ("libvlc_media_list_player_is_playing", dll), paramflags )
libvlc_media_list_player_is_playing.__doc__ = """Is media list playing?
\param p_mlp media list player instance
\return true for playing and false for not playing
"""
if hasattr(dll, 'libvlc_media_list_player_get_state'):
prototype=ctypes.CFUNCTYPE(State, MediaListPlayer)
paramflags=( (1, ), )
libvlc_media_list_player_get_state = prototype( ("libvlc_media_list_player_get_state", dll), paramflags )
libvlc_media_list_player_get_state.__doc__ = """Get current libvlc_state of media list player
\param p_mlp media list player instance
\return libvlc_state_t for media list player
"""
if hasattr(dll, 'libvlc_media_list_player_play_item_at_index'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, MediaListPlayer, ctypes.c_int)
paramflags=(1,), (1,)
libvlc_media_list_player_play_item_at_index = prototype( ("libvlc_media_list_player_play_item_at_index", dll), paramflags )
libvlc_media_list_player_play_item_at_index.__doc__ = """Play media list item at position index
\param p_mlp media list player instance
\param i_index index in media list to play
\return 0 upon success -1 if the item wasn't found
"""
if hasattr(dll, 'libvlc_media_list_player_play_item'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, MediaListPlayer, Media)
paramflags=(1,), (1,)
libvlc_media_list_player_play_item = prototype( ("libvlc_media_list_player_play_item", dll), paramflags )
libvlc_media_list_player_play_item.__doc__ = """Play the given media item
\param p_mlp media list player instance
\param p_md the media instance
\return 0 upon success, -1 if the media is not part of the media list
"""
if hasattr(dll, 'libvlc_media_list_player_stop'):
prototype=ctypes.CFUNCTYPE(None, MediaListPlayer)
paramflags=( (1, ), )
libvlc_media_list_player_stop = prototype( ("libvlc_media_list_player_stop", dll), paramflags )
libvlc_media_list_player_stop.__doc__ = """Stop playing media list
\param p_mlp media list player instance
"""
if hasattr(dll, 'libvlc_media_list_player_next'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, MediaListPlayer)
paramflags=( (1, ), )
libvlc_media_list_player_next = prototype( ("libvlc_media_list_player_next", dll), paramflags )
libvlc_media_list_player_next.__doc__ = """Play next item from media list
\param p_mlp media list player instance
\return 0 upon success -1 if there is no next item
"""
if hasattr(dll, 'libvlc_media_list_player_previous'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, MediaListPlayer)
paramflags=( (1, ), )
libvlc_media_list_player_previous = prototype( ("libvlc_media_list_player_previous", dll), paramflags )
libvlc_media_list_player_previous.__doc__ = """Play previous item from media list
\param p_mlp media list player instance
\return 0 upon success -1 if there is no previous item
"""
if hasattr(dll, 'libvlc_media_list_player_set_playback_mode'):
prototype=ctypes.CFUNCTYPE(None, MediaListPlayer, PlaybackMode)
paramflags=(1,), (1,)
libvlc_media_list_player_set_playback_mode = prototype( ("libvlc_media_list_player_set_playback_mode", dll), paramflags )
libvlc_media_list_player_set_playback_mode.__doc__ = """Sets the playback mode for the playlist
\param p_mlp media list player instance
\param e_mode playback mode specification
"""
if hasattr(dll, 'libvlc_media_player_new'):
prototype=ctypes.CFUNCTYPE(MediaPlayer, Instance)
paramflags=( (1, ), )
libvlc_media_player_new = prototype( ("libvlc_media_player_new", dll), paramflags )
libvlc_media_player_new.__doc__ = """Create an empty Media Player object
\param p_libvlc_instance the libvlc instance in which the Media Player
should be created.
\return a new media player object, or NULL on error.
"""
if hasattr(dll, 'libvlc_media_player_new_from_media'):
prototype=ctypes.CFUNCTYPE(MediaPlayer, Media)
paramflags=( (1, ), )
libvlc_media_player_new_from_media = prototype( ("libvlc_media_player_new_from_media", dll), paramflags )
libvlc_media_player_new_from_media.__doc__ = """Create a Media Player object from a Media
\param p_md the media. Afterwards the p_md can be safely
destroyed.
\return a new media player object, or NULL on error.
"""
if hasattr(dll, 'libvlc_media_player_release'):
prototype=ctypes.CFUNCTYPE(None, MediaPlayer)
paramflags=( (1, ), )
libvlc_media_player_release = prototype( ("libvlc_media_player_release", dll), paramflags )
libvlc_media_player_release.__doc__ = """Release a media_player after use
Decrement the reference count of a media player object. If the
reference count is 0, then libvlc_media_player_release() will
release the media player object. If the media player object
has been released, then it should not be used again.
\param p_mi the Media Player to free
"""
if hasattr(dll, 'libvlc_media_player_retain'):
prototype=ctypes.CFUNCTYPE(None, MediaPlayer)
paramflags=( (1, ), )
libvlc_media_player_retain = prototype( ("libvlc_media_player_retain", dll), paramflags )
libvlc_media_player_retain.__doc__ = """Retain a reference to a media player object. Use
libvlc_media_player_release() to decrement reference count.
\param p_mi media player object
"""
if hasattr(dll, 'libvlc_media_player_set_media'):
prototype=ctypes.CFUNCTYPE(None, MediaPlayer, Media)
paramflags=(1,), (1,)
libvlc_media_player_set_media = prototype( ("libvlc_media_player_set_media", dll), paramflags )
libvlc_media_player_set_media.__doc__ = """Set the media that will be used by the media_player. If any,
previous md will be released.
\param p_mi the Media Player
\param p_md the Media. Afterwards the p_md can be safely
destroyed.
"""
if hasattr(dll, 'libvlc_media_player_get_media'):
prototype=ctypes.CFUNCTYPE(Media, MediaPlayer)
paramflags=( (1, ), )
libvlc_media_player_get_media = prototype( ("libvlc_media_player_get_media", dll), paramflags )
libvlc_media_player_get_media.__doc__ = """Get the media used by the media_player.
\param p_mi the Media Player
\return the media associated with p_mi, or NULL if no
media is associated
"""
if hasattr(dll, 'libvlc_media_player_event_manager'):
prototype=ctypes.CFUNCTYPE(EventManager, MediaPlayer)
paramflags=( (1, ), )
libvlc_media_player_event_manager = prototype( ("libvlc_media_player_event_manager", dll), paramflags )
libvlc_media_player_event_manager.__doc__ = """Get the Event Manager from which the media player send event.
\param p_mi the Media Player
\return the event manager associated with p_mi
"""
if hasattr(dll, 'libvlc_media_player_is_playing'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, MediaPlayer)
paramflags=( (1, ), )
libvlc_media_player_is_playing = prototype( ("libvlc_media_player_is_playing", dll), paramflags )
libvlc_media_player_is_playing.__doc__ = """is_playing
\param p_mi the Media Player
\return 1 if the media player is playing, 0 otherwise
"""
if hasattr(dll, 'libvlc_media_player_play'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, MediaPlayer)
paramflags=( (1, ), )
libvlc_media_player_play = prototype( ("libvlc_media_player_play", dll), paramflags )
libvlc_media_player_play.__doc__ = """Play
\param p_mi the Media Player
\return 0 if playback started (and was already started), or -1 on error.
"""
if hasattr(dll, 'libvlc_media_player_set_pause'):
prototype=ctypes.CFUNCTYPE(None, MediaPlayer, ctypes.c_int)
paramflags=(1,), (1,)
libvlc_media_player_set_pause = prototype( ("libvlc_media_player_set_pause", dll), paramflags )
libvlc_media_player_set_pause.__doc__ = """Pause or resume (no effect if there is no media)
\param mp the Media Player
\param do_pause play/resume if zero, pause if non-zero
\version LibVLC 1.1.1 or later
"""
if hasattr(dll, 'libvlc_media_player_pause'):
prototype=ctypes.CFUNCTYPE(None, MediaPlayer)
paramflags=( (1, ), )
libvlc_media_player_pause = prototype( ("libvlc_media_player_pause", dll), paramflags )
libvlc_media_player_pause.__doc__ = """Toggle pause (no effect if there is no media)
\param p_mi the Media Player
"""
if hasattr(dll, 'libvlc_media_player_stop'):
prototype=ctypes.CFUNCTYPE(None, MediaPlayer)
paramflags=( (1, ), )
libvlc_media_player_stop = prototype( ("libvlc_media_player_stop", dll), paramflags )
libvlc_media_player_stop.__doc__ = """Stop (no effect if there is no media)
\param p_mi the Media Player
"""
if hasattr(dll, 'libvlc_video_set_format'):
prototype=ctypes.CFUNCTYPE(None, MediaPlayer, ctypes.c_char_p, ctypes.c_uint, ctypes.c_uint, ctypes.c_uint)
paramflags=(1,), (1,), (1,), (1,), (1,)
libvlc_video_set_format = prototype( ("libvlc_video_set_format", dll), paramflags )
libvlc_video_set_format.__doc__ = """Set decoded video chroma and dimensions. This only works in combination with
libvlc_video_set_callbacks().
\param mp the media player
\param chroma a four-characters string identifying the chroma
(e.g. "RV32" or "I420")
\param width pixel width
\param height pixel height
\param pitch line pitch (in bytes)
\version LibVLC 1.1.1 or later
"""
if hasattr(dll, 'libvlc_media_player_set_nsobject'):
prototype=ctypes.CFUNCTYPE(None, MediaPlayer, ctypes.c_void_p)
paramflags=(1,), (1,)
libvlc_media_player_set_nsobject = prototype( ("libvlc_media_player_set_nsobject", dll), paramflags )
libvlc_media_player_set_nsobject.__doc__ = """Set the NSView handler where the media player should render its video output.
Use the vout called "macosx".
The drawable is an NSObject that follow the VLCOpenGLVideoViewEmbedding
protocol:
@begincode
\@protocol VLCOpenGLVideoViewEmbedding <NSObject>
- (void)addVoutSubview:(NSView *)view;
- (void)removeVoutSubview:(NSView *)view;
\@end
@endcode
Or it can be an NSView object.
If you want to use it along with Qt4 see the QMacCocoaViewContainer. Then
the following code should work:
@begincode
{
NSView *video = [[NSView alloc] init];
QMacCocoaViewContainer *container = new QMacCocoaViewContainer(video, parent);
libvlc_media_player_set_nsobject(mp, video);
[video release];
}
@endcode
You can find a live example in VLCVideoView in VLCKit.framework.
\param p_mi the Media Player
\param drawable the drawable that is either an NSView or an object following
the VLCOpenGLVideoViewEmbedding protocol.
"""
if hasattr(dll, 'libvlc_media_player_get_nsobject'):
prototype=ctypes.CFUNCTYPE(ctypes.c_void_p, MediaPlayer)
paramflags=( (1, ), )
libvlc_media_player_get_nsobject = prototype( ("libvlc_media_player_get_nsobject", dll), paramflags )
libvlc_media_player_get_nsobject.__doc__ = """Get the NSView handler previously set with libvlc_media_player_set_nsobject().
\param p_mi the Media Player
\return the NSView handler or 0 if none where set
"""
if hasattr(dll, 'libvlc_media_player_set_agl'):
prototype=ctypes.CFUNCTYPE(None, MediaPlayer, ctypes.c_uint32)
paramflags=(1,), (1,)
libvlc_media_player_set_agl = prototype( ("libvlc_media_player_set_agl", dll), paramflags )
libvlc_media_player_set_agl.__doc__ = """Set the agl handler where the media player should render its video output.
\param p_mi the Media Player
\param drawable the agl handler
"""
if hasattr(dll, 'libvlc_media_player_get_agl'):
prototype=ctypes.CFUNCTYPE(ctypes.c_uint32, MediaPlayer)
paramflags=( (1, ), )
libvlc_media_player_get_agl = prototype( ("libvlc_media_player_get_agl", dll), paramflags )
libvlc_media_player_get_agl.__doc__ = """Get the agl handler previously set with libvlc_media_player_set_agl().
\param p_mi the Media Player
\return the agl handler or 0 if none where set
"""
if hasattr(dll, 'libvlc_media_player_set_xwindow'):
prototype=ctypes.CFUNCTYPE(None, MediaPlayer, ctypes.c_uint32)
paramflags=(1,), (1,)
libvlc_media_player_set_xwindow = prototype( ("libvlc_media_player_set_xwindow", dll), paramflags )
libvlc_media_player_set_xwindow.__doc__ = """Set an X Window System drawable where the media player should render its
video output. If LibVLC was built without X11 output support, then this has
no effects.
The specified identifier must correspond to an existing Input/Output class
X11 window. Pixmaps are <b>not</b> supported. The caller shall ensure that
the X11 server is the same as the one the VLC instance has been configured
with.
\param p_mi the Media Player
\param drawable the ID of the X window
"""
if hasattr(dll, 'libvlc_media_player_get_xwindow'):
prototype=ctypes.CFUNCTYPE(ctypes.c_uint32, MediaPlayer)
paramflags=( (1, ), )
libvlc_media_player_get_xwindow = prototype( ("libvlc_media_player_get_xwindow", dll), paramflags )
libvlc_media_player_get_xwindow.__doc__ = """Get the X Window System window identifier previously set with
libvlc_media_player_set_xwindow(). Note that this will return the identifier
even if VLC is not currently using it (for instance if it is playing an
audio-only input).
\param p_mi the Media Player
\return an X window ID, or 0 if none where set.
"""
if hasattr(dll, 'libvlc_media_player_set_hwnd'):
prototype=ctypes.CFUNCTYPE(None, MediaPlayer, ctypes.c_void_p)
paramflags=(1,), (1,)
libvlc_media_player_set_hwnd = prototype( ("libvlc_media_player_set_hwnd", dll), paramflags )
libvlc_media_player_set_hwnd.__doc__ = """Set a Win32/Win64 API window handle (HWND) where the media player should
render its video output. If LibVLC was built without Win32/Win64 API output
support, then this has no effects.
\param p_mi the Media Player
\param drawable windows handle of the drawable
"""
if hasattr(dll, 'libvlc_media_player_get_hwnd'):
prototype=ctypes.CFUNCTYPE(ctypes.c_void_p, MediaPlayer)
paramflags=( (1, ), )
libvlc_media_player_get_hwnd = prototype( ("libvlc_media_player_get_hwnd", dll), paramflags )
libvlc_media_player_get_hwnd.__doc__ = """Get the Windows API window handle (HWND) previously set with
libvlc_media_player_set_hwnd(). The handle will be returned even if LibVLC
is not currently outputting any video to it.
\param p_mi the Media Player
\return a window handle or NULL if there are none.
"""
if hasattr(dll, 'libvlc_media_player_get_length'):
prototype=ctypes.CFUNCTYPE(ctypes.c_longlong, MediaPlayer)
paramflags=( (1, ), )
libvlc_media_player_get_length = prototype( ("libvlc_media_player_get_length", dll), paramflags )
libvlc_media_player_get_length.__doc__ = """Get the current movie length (in ms).
\param p_mi the Media Player
\return the movie length (in ms), or -1 if there is no media.
"""
if hasattr(dll, 'libvlc_media_player_get_time'):
prototype=ctypes.CFUNCTYPE(ctypes.c_longlong, MediaPlayer)
paramflags=( (1, ), )
libvlc_media_player_get_time = prototype( ("libvlc_media_player_get_time", dll), paramflags )
libvlc_media_player_get_time.__doc__ = """Get the current movie time (in ms).
\param p_mi the Media Player
\return the movie time (in ms), or -1 if there is no media.
"""
if hasattr(dll, 'libvlc_media_player_set_time'):
prototype=ctypes.CFUNCTYPE(None, MediaPlayer, ctypes.c_longlong)
paramflags=(1,), (1,)
libvlc_media_player_set_time = prototype( ("libvlc_media_player_set_time", dll), paramflags )
libvlc_media_player_set_time.__doc__ = """Set the movie time (in ms). This has no effect if no media is being played.
Not all formats and protocols support this.
\param p_mi the Media Player
\param i_time the movie time (in ms).
"""
if hasattr(dll, 'libvlc_media_player_get_position'):
prototype=ctypes.CFUNCTYPE(ctypes.c_float, MediaPlayer)
paramflags=( (1, ), )
libvlc_media_player_get_position = prototype( ("libvlc_media_player_get_position", dll), paramflags )
libvlc_media_player_get_position.__doc__ = """Get movie position.
\param p_mi the Media Player
\return movie position, or -1. in case of error
"""
if hasattr(dll, 'libvlc_media_player_set_position'):
prototype=ctypes.CFUNCTYPE(None, MediaPlayer, ctypes.c_float)
paramflags=(1,), (1,)
libvlc_media_player_set_position = prototype( ("libvlc_media_player_set_position", dll), paramflags )
libvlc_media_player_set_position.__doc__ = """Set movie position. This has no effect if playback is not enabled.
This might not work depending on the underlying input format and protocol.
\param p_mi the Media Player
\param f_pos the position
"""
if hasattr(dll, 'libvlc_media_player_set_chapter'):
prototype=ctypes.CFUNCTYPE(None, MediaPlayer, ctypes.c_int)
paramflags=(1,), (1,)
libvlc_media_player_set_chapter = prototype( ("libvlc_media_player_set_chapter", dll), paramflags )
libvlc_media_player_set_chapter.__doc__ = """Set movie chapter (if applicable).
\param p_mi the Media Player
\param i_chapter chapter number to play
"""
if hasattr(dll, 'libvlc_media_player_get_chapter'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, MediaPlayer)
paramflags=( (1, ), )
libvlc_media_player_get_chapter = prototype( ("libvlc_media_player_get_chapter", dll), paramflags )
libvlc_media_player_get_chapter.__doc__ = """Get movie chapter.
\param p_mi the Media Player
\return chapter number currently playing, or -1 if there is no media.
"""
if hasattr(dll, 'libvlc_media_player_get_chapter_count'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, MediaPlayer)
paramflags=( (1, ), )
libvlc_media_player_get_chapter_count = prototype( ("libvlc_media_player_get_chapter_count", dll), paramflags )
libvlc_media_player_get_chapter_count.__doc__ = """Get movie chapter count
\param p_mi the Media Player
\return number of chapters in movie, or -1.
"""
if hasattr(dll, 'libvlc_media_player_will_play'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, MediaPlayer)
paramflags=( (1, ), )
libvlc_media_player_will_play = prototype( ("libvlc_media_player_will_play", dll), paramflags )
libvlc_media_player_will_play.__doc__ = """Is the player able to play
\param p_mi the Media Player
\return boolean
"""
if hasattr(dll, 'libvlc_media_player_get_chapter_count_for_title'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, MediaPlayer, ctypes.c_int)
paramflags=(1,), (1,)
libvlc_media_player_get_chapter_count_for_title = prototype( ("libvlc_media_player_get_chapter_count_for_title", dll), paramflags )
libvlc_media_player_get_chapter_count_for_title.__doc__ = """Get title chapter count
\param p_mi the Media Player
\param i_title title
\return number of chapters in title, or -1
"""
if hasattr(dll, 'libvlc_media_player_set_title'):
prototype=ctypes.CFUNCTYPE(None, MediaPlayer, ctypes.c_int)
paramflags=(1,), (1,)
libvlc_media_player_set_title = prototype( ("libvlc_media_player_set_title", dll), paramflags )
libvlc_media_player_set_title.__doc__ = """Set movie title
\param p_mi the Media Player
\param i_title title number to play
"""
if hasattr(dll, 'libvlc_media_player_get_title'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, MediaPlayer)
paramflags=( (1, ), )
libvlc_media_player_get_title = prototype( ("libvlc_media_player_get_title", dll), paramflags )
libvlc_media_player_get_title.__doc__ = """Get movie title
\param p_mi the Media Player
\return title number currently playing, or -1
"""
if hasattr(dll, 'libvlc_media_player_get_title_count'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, MediaPlayer)
paramflags=( (1, ), )
libvlc_media_player_get_title_count = prototype( ("libvlc_media_player_get_title_count", dll), paramflags )
libvlc_media_player_get_title_count.__doc__ = """Get movie title count
\param p_mi the Media Player
\return title number count, or -1
"""
if hasattr(dll, 'libvlc_media_player_previous_chapter'):
prototype=ctypes.CFUNCTYPE(None, MediaPlayer)
paramflags=( (1, ), )
libvlc_media_player_previous_chapter = prototype( ("libvlc_media_player_previous_chapter", dll), paramflags )
libvlc_media_player_previous_chapter.__doc__ = """Set previous chapter (if applicable)
\param p_mi the Media Player
"""
if hasattr(dll, 'libvlc_media_player_next_chapter'):
prototype=ctypes.CFUNCTYPE(None, MediaPlayer)
paramflags=( (1, ), )
libvlc_media_player_next_chapter = prototype( ("libvlc_media_player_next_chapter", dll), paramflags )
libvlc_media_player_next_chapter.__doc__ = """Set next chapter (if applicable)
\param p_mi the Media Player
"""
if hasattr(dll, 'libvlc_media_player_get_rate'):
prototype=ctypes.CFUNCTYPE(ctypes.c_float, MediaPlayer)
paramflags=( (1, ), )
libvlc_media_player_get_rate = prototype( ("libvlc_media_player_get_rate", dll), paramflags )
libvlc_media_player_get_rate.__doc__ = """Get the requested movie play rate.
@warning Depending on the underlying media, the requested rate may be
different from the real playback rate.
\param p_mi the Media Player
\return movie play rate
"""
if hasattr(dll, 'libvlc_media_player_set_rate'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, MediaPlayer, ctypes.c_float)
paramflags=(1,), (1,)
libvlc_media_player_set_rate = prototype( ("libvlc_media_player_set_rate", dll), paramflags )
libvlc_media_player_set_rate.__doc__ = """Set movie play rate
\param p_mi the Media Player
\param rate movie play rate to set
\return -1 if an error was detected, 0 otherwise (but even then, it might
not actually work depending on the underlying media protocol)
"""
if hasattr(dll, 'libvlc_media_player_get_state'):
prototype=ctypes.CFUNCTYPE(State, MediaPlayer)
paramflags=( (1, ), )
libvlc_media_player_get_state = prototype( ("libvlc_media_player_get_state", dll), paramflags )
libvlc_media_player_get_state.__doc__ = """Get current movie state
\param p_mi the Media Player
\return the current state of the media player (playing, paused, ...) \see libvlc_state_t
"""
if hasattr(dll, 'libvlc_media_player_get_fps'):
prototype=ctypes.CFUNCTYPE(ctypes.c_float, MediaPlayer)
paramflags=( (1, ), )
libvlc_media_player_get_fps = prototype( ("libvlc_media_player_get_fps", dll), paramflags )
libvlc_media_player_get_fps.__doc__ = """Get movie fps rate
\param p_mi the Media Player
\return frames per second (fps) for this playing movie, or 0 if unspecified
"""
if hasattr(dll, 'libvlc_media_player_has_vout'):
prototype=ctypes.CFUNCTYPE(ctypes.c_uint, MediaPlayer)
paramflags=( (1, ), )
libvlc_media_player_has_vout = prototype( ("libvlc_media_player_has_vout", dll), paramflags )
libvlc_media_player_has_vout.__doc__ = """How many video outputs does this media player have?
\param p_mi the media player
\return the number of video outputs
"""
if hasattr(dll, 'libvlc_media_player_is_seekable'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, MediaPlayer)
paramflags=( (1, ), )
libvlc_media_player_is_seekable = prototype( ("libvlc_media_player_is_seekable", dll), paramflags )
libvlc_media_player_is_seekable.__doc__ = """Is this media player seekable?
\param p_mi the media player
\return true if the media player can seek
"""
if hasattr(dll, 'libvlc_media_player_can_pause'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, MediaPlayer)
paramflags=( (1, ), )
libvlc_media_player_can_pause = prototype( ("libvlc_media_player_can_pause", dll), paramflags )
libvlc_media_player_can_pause.__doc__ = """Can this media player be paused?
\param p_mi the media player
\return true if the media player can pause
"""
if hasattr(dll, 'libvlc_media_player_next_frame'):
prototype=ctypes.CFUNCTYPE(None, MediaPlayer)
paramflags=( (1, ), )
libvlc_media_player_next_frame = prototype( ("libvlc_media_player_next_frame", dll), paramflags )
libvlc_media_player_next_frame.__doc__ = """Display the next frame (if supported)
\param p_mi the media player
"""
if hasattr(dll, 'libvlc_track_description_release'):
prototype=ctypes.CFUNCTYPE(None, ctypes.POINTER(TrackDescription))
paramflags=( (1, ), )
libvlc_track_description_release = prototype( ("libvlc_track_description_release", dll), paramflags )
libvlc_track_description_release.__doc__ = """Release (free) libvlc_track_description_t
\param p_track_description the structure to release
"""
if hasattr(dll, 'libvlc_toggle_fullscreen'):
prototype=ctypes.CFUNCTYPE(None, MediaPlayer)
paramflags=( (1, ), )
libvlc_toggle_fullscreen = prototype( ("libvlc_toggle_fullscreen", dll), paramflags )
libvlc_toggle_fullscreen.__doc__ = """Toggle fullscreen status on non-embedded video outputs.
@warning The same limitations applies to this function
as to libvlc_set_fullscreen().
\param p_mi the media player
"""
if hasattr(dll, 'libvlc_set_fullscreen'):
prototype=ctypes.CFUNCTYPE(None, MediaPlayer, ctypes.c_int)
paramflags=(1,), (1,)
libvlc_set_fullscreen = prototype( ("libvlc_set_fullscreen", dll), paramflags )
libvlc_set_fullscreen.__doc__ = """Enable or disable fullscreen.
@warning With most window managers, only a top-level windows can be in
full-screen mode. Hence, this function will not operate properly if
libvlc_media_player_set_xwindow() was used to embed the video in a
non-top-level window. In that case, the embedding window must be reparented
to the root window <b>before</b> fullscreen mode is enabled. You will want
to reparent it back to its normal parent when disabling fullscreen.
\param p_mi the media player
\param b_fullscreen boolean for fullscreen status
"""
if hasattr(dll, 'libvlc_get_fullscreen'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, MediaPlayer)
paramflags=( (1, ), )
libvlc_get_fullscreen = prototype( ("libvlc_get_fullscreen", dll), paramflags )
libvlc_get_fullscreen.__doc__ = """Get current fullscreen status.
\param p_mi the media player
\return the fullscreen status (boolean)
"""
if hasattr(dll, 'libvlc_video_set_key_input'):
prototype=ctypes.CFUNCTYPE(None, MediaPlayer, ctypes.c_uint)
paramflags=(1,), (1,)
libvlc_video_set_key_input = prototype( ("libvlc_video_set_key_input", dll), paramflags )
libvlc_video_set_key_input.__doc__ = """Enable or disable key press events handling, according to the LibVLC hotkeys
configuration. By default and for historical reasons, keyboard events are
handled by the LibVLC video widget.
\note On X11, there can be only one subscriber for key press and mouse
click events per window. If your application has subscribed to those events
for the X window ID of the video widget, then LibVLC will not be able to
handle key presses and mouse clicks in any case.
\warning This function is only implemented for X11 and Win32 at the moment.
\param p_mi the media player
\param on true to handle key press events, false to ignore them.
"""
if hasattr(dll, 'libvlc_video_set_mouse_input'):
prototype=ctypes.CFUNCTYPE(None, MediaPlayer, ctypes.c_uint)
paramflags=(1,), (1,)
libvlc_video_set_mouse_input = prototype( ("libvlc_video_set_mouse_input", dll), paramflags )
libvlc_video_set_mouse_input.__doc__ = """Enable or disable mouse click events handling. By default, those events are
handled. This is needed for DVD menus to work, as well as a few video
filters such as "puzzle".
\note See also libvlc_video_set_key_input().
\warning This function is only implemented for X11 and Win32 at the moment.
\param p_mi the media player
\param on true to handle mouse click events, false to ignore them.
"""
if hasattr(dll, 'libvlc_video_get_size'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, MediaPlayer, ctypes.c_uint, ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_uint))
paramflags=(1,), (1,), (1,), (1,)
libvlc_video_get_size = prototype( ("libvlc_video_get_size", dll), paramflags )
libvlc_video_get_size.__doc__ = """Get the pixel dimensions of a video.
\param p_mi media player
\param num number of the video (starting from, and most commonly 0)
\param px pointer to get the pixel width [OUT]
\param py pointer to get the pixel height [OUT]
\return 0 on success, -1 if the specified video does not exist
"""
if hasattr(dll, 'libvlc_video_get_cursor'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, MediaPlayer, ctypes.c_uint, ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_int))
paramflags=(1,), (1,), (1,), (1,)
libvlc_video_get_cursor = prototype( ("libvlc_video_get_cursor", dll), paramflags )
libvlc_video_get_cursor.__doc__ = """Get the mouse pointer coordinates over a video.
Coordinates are expressed in terms of the decoded video resolution,
<b>not</b> in terms of pixels on the screen/viewport (to get the latter,
you can query your windowing system directly).
Either of the coordinates may be negative or larger than the corresponding
dimension of the video, if the cursor is outside the rendering area.
@warning The coordinates may be out-of-date if the pointer is not located
on the video rendering area. LibVLC does not track the pointer if it is
outside of the video widget.
@note LibVLC does not support multiple pointers (it does of course support
multiple input devices sharing the same pointer) at the moment.
\param p_mi media player
\param num number of the video (starting from, and most commonly 0)
\param px pointer to get the abscissa [OUT]
\param py pointer to get the ordinate [OUT]
\return 0 on success, -1 if the specified video does not exist
"""
if hasattr(dll, 'libvlc_video_get_scale'):
prototype=ctypes.CFUNCTYPE(ctypes.c_float, MediaPlayer)
paramflags=( (1, ), )
libvlc_video_get_scale = prototype( ("libvlc_video_get_scale", dll), paramflags )
libvlc_video_get_scale.__doc__ = """Get the current video scaling factor.
See also libvlc_video_set_scale().
\param p_mi the media player
\return the currently configured zoom factor, or 0. if the video is set
to fit to the output window/drawable automatically.
"""
if hasattr(dll, 'libvlc_video_set_scale'):
prototype=ctypes.CFUNCTYPE(None, MediaPlayer, ctypes.c_float)
paramflags=(1,), (1,)
libvlc_video_set_scale = prototype( ("libvlc_video_set_scale", dll), paramflags )
libvlc_video_set_scale.__doc__ = """Set the video scaling factor. That is the ratio of the number of pixels on
screen to the number of pixels in the original decoded video in each
dimension. Zero is a special value; it will adjust the video to the output
window/drawable (in windowed mode) or the entire screen.
Note that not all video outputs support scaling.
\param p_mi the media player
\param f_factor the scaling factor, or zero
"""
if hasattr(dll, 'libvlc_video_get_aspect_ratio'):
prototype=ctypes.CFUNCTYPE(ctypes.c_char_p, MediaPlayer)
paramflags=( (1, ), )
libvlc_video_get_aspect_ratio = prototype( ("libvlc_video_get_aspect_ratio", dll), paramflags )
libvlc_video_get_aspect_ratio.__doc__ = """Get current video aspect ratio.
\param p_mi the media player
\return the video aspect ratio or NULL if unspecified
(the result must be released with free()).
"""
if hasattr(dll, 'libvlc_video_set_aspect_ratio'):
prototype=ctypes.CFUNCTYPE(None, MediaPlayer, ctypes.c_char_p)
paramflags=(1,), (1,)
libvlc_video_set_aspect_ratio = prototype( ("libvlc_video_set_aspect_ratio", dll), paramflags )
libvlc_video_set_aspect_ratio.__doc__ = """Set new video aspect ratio.
\param p_mi the media player
\param psz_aspect new video aspect-ratio or NULL to reset to default
\note Invalid aspect ratios are ignored.
"""
if hasattr(dll, 'libvlc_video_get_spu'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, MediaPlayer)
paramflags=( (1, ), )
libvlc_video_get_spu = prototype( ("libvlc_video_get_spu", dll), paramflags )
libvlc_video_get_spu.__doc__ = """Get current video subtitle.
\param p_mi the media player
\return the video subtitle selected, or -1 if none
"""
if hasattr(dll, 'libvlc_video_get_spu_count'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, MediaPlayer)
paramflags=( (1, ), )
libvlc_video_get_spu_count = prototype( ("libvlc_video_get_spu_count", dll), paramflags )
libvlc_video_get_spu_count.__doc__ = """Get the number of available video subtitles.
\param p_mi the media player
\return the number of available video subtitles
"""
if hasattr(dll, 'libvlc_video_get_spu_description'):
prototype=ctypes.CFUNCTYPE(ctypes.POINTER(TrackDescription), MediaPlayer)
paramflags=( (1, ), )
libvlc_video_get_spu_description = prototype( ("libvlc_video_get_spu_description", dll), paramflags )
libvlc_video_get_spu_description.__doc__ = """Get the description of available video subtitles.
\param p_mi the media player
\return list containing description of available video subtitles
"""
if hasattr(dll, 'libvlc_video_set_spu'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, MediaPlayer, ctypes.c_uint)
paramflags=(1,), (1,)
libvlc_video_set_spu = prototype( ("libvlc_video_set_spu", dll), paramflags )
libvlc_video_set_spu.__doc__ = """Set new video subtitle.
\param p_mi the media player
\param i_spu new video subtitle to select
\return 0 on success, -1 if out of range
"""
if hasattr(dll, 'libvlc_video_set_subtitle_file'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, MediaPlayer, ctypes.c_char_p)
paramflags=(1,), (1,)
libvlc_video_set_subtitle_file = prototype( ("libvlc_video_set_subtitle_file", dll), paramflags )
libvlc_video_set_subtitle_file.__doc__ = """Set new video subtitle file.
\param p_mi the media player
\param psz_subtitle new video subtitle file
\return the success status (boolean)
"""
if hasattr(dll, 'libvlc_video_get_title_description'):
prototype=ctypes.CFUNCTYPE(ctypes.POINTER(TrackDescription), MediaPlayer)
paramflags=( (1, ), )
libvlc_video_get_title_description = prototype( ("libvlc_video_get_title_description", dll), paramflags )
libvlc_video_get_title_description.__doc__ = """Get the description of available titles.
\param p_mi the media player
\return list containing description of available titles
"""
if hasattr(dll, 'libvlc_video_get_chapter_description'):
prototype=ctypes.CFUNCTYPE(ctypes.POINTER(TrackDescription), MediaPlayer, ctypes.c_int)
paramflags=(1,), (1,)
libvlc_video_get_chapter_description = prototype( ("libvlc_video_get_chapter_description", dll), paramflags )
libvlc_video_get_chapter_description.__doc__ = """Get the description of available chapters for specific title.
\param p_mi the media player
\param i_title selected title
\return list containing description of available chapter for title i_title
"""
if hasattr(dll, 'libvlc_video_get_crop_geometry'):
prototype=ctypes.CFUNCTYPE(ctypes.c_char_p, MediaPlayer)
paramflags=( (1, ), )
libvlc_video_get_crop_geometry = prototype( ("libvlc_video_get_crop_geometry", dll), paramflags )
libvlc_video_get_crop_geometry.__doc__ = """Get current crop filter geometry.
\param p_mi the media player
\return the crop filter geometry or NULL if unset
"""
if hasattr(dll, 'libvlc_video_set_crop_geometry'):
prototype=ctypes.CFUNCTYPE(None, MediaPlayer, ctypes.c_char_p)
paramflags=(1,), (1,)
libvlc_video_set_crop_geometry = prototype( ("libvlc_video_set_crop_geometry", dll), paramflags )
libvlc_video_set_crop_geometry.__doc__ = """Set new crop filter geometry.
\param p_mi the media player
\param psz_geometry new crop filter geometry (NULL to unset)
"""
if hasattr(dll, 'libvlc_video_get_teletext'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, MediaPlayer)
paramflags=( (1, ), )
libvlc_video_get_teletext = prototype( ("libvlc_video_get_teletext", dll), paramflags )
libvlc_video_get_teletext.__doc__ = """Get current teletext page requested.
\param p_mi the media player
\return the current teletext page requested.
"""
if hasattr(dll, 'libvlc_video_set_teletext'):
prototype=ctypes.CFUNCTYPE(None, MediaPlayer, ctypes.c_int)
paramflags=(1,), (1,)
libvlc_video_set_teletext = prototype( ("libvlc_video_set_teletext", dll), paramflags )
libvlc_video_set_teletext.__doc__ = """Set new teletext page to retrieve.
\param p_mi the media player
\param i_page teletex page number requested
"""
if hasattr(dll, 'libvlc_toggle_teletext'):
prototype=ctypes.CFUNCTYPE(None, MediaPlayer)
paramflags=( (1, ), )
libvlc_toggle_teletext = prototype( ("libvlc_toggle_teletext", dll), paramflags )
libvlc_toggle_teletext.__doc__ = """Toggle teletext transparent status on video output.
\param p_mi the media player
"""
if hasattr(dll, 'libvlc_video_get_track_count'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, MediaPlayer)
paramflags=( (1, ), )
libvlc_video_get_track_count = prototype( ("libvlc_video_get_track_count", dll), paramflags )
libvlc_video_get_track_count.__doc__ = """Get number of available video tracks.
\param p_mi media player
\return the number of available video tracks (int)
"""
if hasattr(dll, 'libvlc_video_get_track_description'):
prototype=ctypes.CFUNCTYPE(ctypes.POINTER(TrackDescription), MediaPlayer)
paramflags=( (1, ), )
libvlc_video_get_track_description = prototype( ("libvlc_video_get_track_description", dll), paramflags )
libvlc_video_get_track_description.__doc__ = """Get the description of available video tracks.
\param p_mi media player
\return list with description of available video tracks, or NULL on error
"""
if hasattr(dll, 'libvlc_video_get_track'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, MediaPlayer)
paramflags=( (1, ), )
libvlc_video_get_track = prototype( ("libvlc_video_get_track", dll), paramflags )
libvlc_video_get_track.__doc__ = """Get current video track.
\param p_mi media player
\return the video track (int) or -1 if none
"""
if hasattr(dll, 'libvlc_video_set_track'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, MediaPlayer, ctypes.c_int)
paramflags=(1,), (1,)
libvlc_video_set_track = prototype( ("libvlc_video_set_track", dll), paramflags )
libvlc_video_set_track.__doc__ = """Set video track.
\param p_mi media player
\param i_track the track (int)
\return 0 on success, -1 if out of range
"""
if hasattr(dll, 'libvlc_video_take_snapshot'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, MediaPlayer, ctypes.c_uint, ctypes.c_char_p, ctypes.c_int, ctypes.c_int)
paramflags=(1,), (1,), (1,), (1,), (1,)
libvlc_video_take_snapshot = prototype( ("libvlc_video_take_snapshot", dll), paramflags )
libvlc_video_take_snapshot.__doc__ = """Take a snapshot of the current video window.
If i_width AND i_height is 0, original size is used.
If i_width XOR i_height is 0, original aspect-ratio is preserved.
\param p_mi media player instance
\param num number of video output (typically 0 for the first/only one)
\param psz_filepath the path where to save the screenshot to
\param i_width the snapshot's width
\param i_height the snapshot's height
\return 0 on success, -1 if the video was not found
"""
if hasattr(dll, 'libvlc_video_set_deinterlace'):
prototype=ctypes.CFUNCTYPE(None, MediaPlayer, ctypes.c_char_p)
paramflags=(1,), (1,)
libvlc_video_set_deinterlace = prototype( ("libvlc_video_set_deinterlace", dll), paramflags )
libvlc_video_set_deinterlace.__doc__ = """Enable or disable deinterlace filter
\param p_mi libvlc media player
\param psz_mode type of deinterlace filter, NULL to disable
"""
if hasattr(dll, 'libvlc_video_get_marquee_int'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, MediaPlayer, ctypes.c_uint)
paramflags=(1,), (1,)
libvlc_video_get_marquee_int = prototype( ("libvlc_video_get_marquee_int", dll), paramflags )
libvlc_video_get_marquee_int.__doc__ = """Get an integer marquee option value
\param p_mi libvlc media player
\param option marq option to get \see libvlc_video_marquee_int_option_t
"""
if hasattr(dll, 'libvlc_video_get_marquee_string'):
prototype=ctypes.CFUNCTYPE(ctypes.c_char_p, MediaPlayer, ctypes.c_uint)
paramflags=(1,), (1,)
libvlc_video_get_marquee_string = prototype( ("libvlc_video_get_marquee_string", dll), paramflags )
libvlc_video_get_marquee_string.__doc__ = """Get a string marquee option value
\param p_mi libvlc media player
\param option marq option to get \see libvlc_video_marquee_string_option_t
"""
if hasattr(dll, 'libvlc_video_set_marquee_int'):
prototype=ctypes.CFUNCTYPE(None, MediaPlayer, ctypes.c_uint, ctypes.c_int)
paramflags=(1,), (1,), (1,)
libvlc_video_set_marquee_int = prototype( ("libvlc_video_set_marquee_int", dll), paramflags )
libvlc_video_set_marquee_int.__doc__ = """Enable, disable or set an integer marquee option
Setting libvlc_marquee_Enable has the side effect of enabling (arg !0)
or disabling (arg 0) the marq filter.
\param p_mi libvlc media player
\param option marq option to set \see libvlc_video_marquee_int_option_t
\param i_val marq option value
"""
if hasattr(dll, 'libvlc_video_set_marquee_string'):
prototype=ctypes.CFUNCTYPE(None, MediaPlayer, ctypes.c_uint, ctypes.c_char_p)
paramflags=(1,), (1,), (1,)
libvlc_video_set_marquee_string = prototype( ("libvlc_video_set_marquee_string", dll), paramflags )
libvlc_video_set_marquee_string.__doc__ = """Set a marquee string option
\param p_mi libvlc media player
\param option marq option to set \see libvlc_video_marquee_string_option_t
\param psz_text marq option value
"""
if hasattr(dll, 'libvlc_video_get_logo_int'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, MediaPlayer, ctypes.c_uint)
paramflags=(1,), (1,)
libvlc_video_get_logo_int = prototype( ("libvlc_video_get_logo_int", dll), paramflags )
libvlc_video_get_logo_int.__doc__ = """Get integer logo option.
\param p_mi libvlc media player instance
\param option logo option to get, values of libvlc_video_logo_option_t
"""
if hasattr(dll, 'libvlc_video_set_logo_int'):
prototype=ctypes.CFUNCTYPE(None, MediaPlayer, ctypes.c_uint, ctypes.c_int)
paramflags=(1,), (1,), (1,)
libvlc_video_set_logo_int = prototype( ("libvlc_video_set_logo_int", dll), paramflags )
libvlc_video_set_logo_int.__doc__ = """Set logo option as integer. Options that take a different type value
are ignored.
Passing libvlc_logo_enable as option value has the side effect of
starting (arg !0) or stopping (arg 0) the logo filter.
\param p_mi libvlc media player instance
\param option logo option to set, values of libvlc_video_logo_option_t
\param value logo option value
"""
if hasattr(dll, 'libvlc_video_set_logo_string'):
prototype=ctypes.CFUNCTYPE(None, MediaPlayer, ctypes.c_uint, ctypes.c_char_p)
paramflags=(1,), (1,), (1,)
libvlc_video_set_logo_string = prototype( ("libvlc_video_set_logo_string", dll), paramflags )
libvlc_video_set_logo_string.__doc__ = """Set logo option as string. Options that take a different type value
are ignored.
\param p_mi libvlc media player instance
\param option logo option to set, values of libvlc_video_logo_option_t
\param psz_value logo option value
"""
if hasattr(dll, 'libvlc_video_get_adjust_int'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, MediaPlayer, ctypes.c_uint)
paramflags=(1,), (1,)
libvlc_video_get_adjust_int = prototype( ("libvlc_video_get_adjust_int", dll), paramflags )
libvlc_video_get_adjust_int.__doc__ = """Get integer adjust option.
\param p_mi libvlc media player instance
\param option adjust option to get, values of libvlc_video_adjust_option_t
\version LibVLC 1.1.1 and later.
"""
if hasattr(dll, 'libvlc_video_set_adjust_int'):
prototype=ctypes.CFUNCTYPE(None, MediaPlayer, ctypes.c_uint, ctypes.c_int)
paramflags=(1,), (1,), (1,)
libvlc_video_set_adjust_int = prototype( ("libvlc_video_set_adjust_int", dll), paramflags )
libvlc_video_set_adjust_int.__doc__ = """Set adjust option as integer. Options that take a different type value
are ignored.
Passing libvlc_adjust_enable as option value has the side effect of
starting (arg !0) or stopping (arg 0) the adjust filter.
\param p_mi libvlc media player instance
\param option adust option to set, values of libvlc_video_adjust_option_t
\param value adjust option value
\version LibVLC 1.1.1 and later.
"""
if hasattr(dll, 'libvlc_video_get_adjust_float'):
prototype=ctypes.CFUNCTYPE(ctypes.c_float, MediaPlayer, ctypes.c_uint)
paramflags=(1,), (1,)
libvlc_video_get_adjust_float = prototype( ("libvlc_video_get_adjust_float", dll), paramflags )
libvlc_video_get_adjust_float.__doc__ = """Get float adjust option.
\param p_mi libvlc media player instance
\param option adjust option to get, values of libvlc_video_adjust_option_t
\version LibVLC 1.1.1 and later.
"""
if hasattr(dll, 'libvlc_video_set_adjust_float'):
prototype=ctypes.CFUNCTYPE(None, MediaPlayer, ctypes.c_uint, ctypes.c_float)
paramflags=(1,), (1,), (1,)
libvlc_video_set_adjust_float = prototype( ("libvlc_video_set_adjust_float", dll), paramflags )
libvlc_video_set_adjust_float.__doc__ = """Set adjust option as float. Options that take a different type value
are ignored.
\param p_mi libvlc media player instance
\param option adust option to set, values of libvlc_video_adjust_option_t
\param value adjust option value
\version LibVLC 1.1.1 and later.
"""
if hasattr(dll, 'libvlc_audio_output_list_get'):
prototype=ctypes.CFUNCTYPE(ctypes.POINTER(AudioOutput), Instance)
paramflags=( (1, ), )
libvlc_audio_output_list_get = prototype( ("libvlc_audio_output_list_get", dll), paramflags )
libvlc_audio_output_list_get.__doc__ = """Get the list of available audio outputs
\param p_instance libvlc instance
\return list of available audio outputs. It must be freed it with
In case of error, NULL is returned.
"""
if hasattr(dll, 'libvlc_audio_output_list_release'):
prototype=ctypes.CFUNCTYPE(None, ctypes.POINTER(AudioOutput))
paramflags=( (1, ), )
libvlc_audio_output_list_release = prototype( ("libvlc_audio_output_list_release", dll), paramflags )
libvlc_audio_output_list_release.__doc__ = """Free the list of available audio outputs
\param p_list list with audio outputs for release
"""
if hasattr(dll, 'libvlc_audio_output_set'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, MediaPlayer, ctypes.c_char_p)
paramflags=(1,), (1,)
libvlc_audio_output_set = prototype( ("libvlc_audio_output_set", dll), paramflags )
libvlc_audio_output_set.__doc__ = """Set the audio output.
Change will be applied after stop and play.
\param p_mi media player
\param psz_name name of audio output,
use psz_name of \see libvlc_audio_output_t
\return true if function succeded
"""
if hasattr(dll, 'libvlc_audio_output_device_count'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, Instance, ctypes.c_char_p)
paramflags=(1,), (1,)
libvlc_audio_output_device_count = prototype( ("libvlc_audio_output_device_count", dll), paramflags )
libvlc_audio_output_device_count.__doc__ = """Get count of devices for audio output, these devices are hardware oriented
like analor or digital output of sound card
\param p_instance libvlc instance
\param psz_audio_output - name of audio output, \see libvlc_audio_output_t
\return number of devices
"""
if hasattr(dll, 'libvlc_audio_output_device_longname'):
prototype=ctypes.CFUNCTYPE(ctypes.c_char_p, Instance, ctypes.c_char_p, ctypes.c_int)
paramflags=(1,), (1,), (1,)
libvlc_audio_output_device_longname = prototype( ("libvlc_audio_output_device_longname", dll), paramflags )
libvlc_audio_output_device_longname.__doc__ = """Get long name of device, if not available short name given
\param p_instance libvlc instance
\param psz_audio_output - name of audio output, \see libvlc_audio_output_t
\param i_device device index
\return long name of device
"""
if hasattr(dll, 'libvlc_audio_output_device_id'):
prototype=ctypes.CFUNCTYPE(ctypes.c_char_p, Instance, ctypes.c_char_p, ctypes.c_int)
paramflags=(1,), (1,), (1,)
libvlc_audio_output_device_id = prototype( ("libvlc_audio_output_device_id", dll), paramflags )
libvlc_audio_output_device_id.__doc__ = """Get id name of device
\param p_instance libvlc instance
\param psz_audio_output - name of audio output, \see libvlc_audio_output_t
\param i_device device index
\return id name of device, use for setting device, need to be free after use
"""
if hasattr(dll, 'libvlc_audio_output_device_set'):
prototype=ctypes.CFUNCTYPE(None, MediaPlayer, ctypes.c_char_p, ctypes.c_char_p)
paramflags=(1,), (1,), (1,)
libvlc_audio_output_device_set = prototype( ("libvlc_audio_output_device_set", dll), paramflags )
libvlc_audio_output_device_set.__doc__ = """Set audio output device. Changes are only effective after stop and play.
\param p_mi media player
\param psz_audio_output - name of audio output, \see libvlc_audio_output_t
\param psz_device_id device
"""
if hasattr(dll, 'libvlc_audio_output_get_device_type'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, MediaPlayer)
paramflags=( (1, ), )
libvlc_audio_output_get_device_type = prototype( ("libvlc_audio_output_get_device_type", dll), paramflags )
libvlc_audio_output_get_device_type.__doc__ = """Get current audio device type. Device type describes something like
character of output sound - stereo sound, 2.1, 5.1 etc
\param p_mi media player
\return the audio devices type \see libvlc_audio_output_device_types_t
"""
if hasattr(dll, 'libvlc_audio_output_set_device_type'):
prototype=ctypes.CFUNCTYPE(None, MediaPlayer, ctypes.c_int)
paramflags=(1,), (1,)
libvlc_audio_output_set_device_type = prototype( ("libvlc_audio_output_set_device_type", dll), paramflags )
libvlc_audio_output_set_device_type.__doc__ = """Set current audio device type.
\param p_mi vlc instance
\param device_type the audio device type,
"""
if hasattr(dll, 'libvlc_audio_toggle_mute'):
prototype=ctypes.CFUNCTYPE(None, MediaPlayer)
paramflags=( (1, ), )
libvlc_audio_toggle_mute = prototype( ("libvlc_audio_toggle_mute", dll), paramflags )
libvlc_audio_toggle_mute.__doc__ = """Toggle mute status.
\param p_mi media player
"""
if hasattr(dll, 'libvlc_audio_get_mute'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, MediaPlayer)
paramflags=( (1, ), )
libvlc_audio_get_mute = prototype( ("libvlc_audio_get_mute", dll), paramflags )
libvlc_audio_get_mute.__doc__ = """Get current mute status.
\param p_mi media player
\return the mute status (boolean)
"""
if hasattr(dll, 'libvlc_audio_set_mute'):
prototype=ctypes.CFUNCTYPE(None, MediaPlayer, ctypes.c_int)
paramflags=(1,), (1,)
libvlc_audio_set_mute = prototype( ("libvlc_audio_set_mute", dll), paramflags )
libvlc_audio_set_mute.__doc__ = """Set mute status.
\param p_mi media player
\param status If status is true then mute, otherwise unmute
"""
if hasattr(dll, 'libvlc_audio_get_volume'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, MediaPlayer)
paramflags=( (1, ), )
libvlc_audio_get_volume = prototype( ("libvlc_audio_get_volume", dll), paramflags )
libvlc_audio_get_volume.__doc__ = """Get current audio level.
\param p_mi media player
\return the audio level (int)
"""
if hasattr(dll, 'libvlc_audio_set_volume'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, MediaPlayer, ctypes.c_int)
paramflags=(1,), (1,)
libvlc_audio_set_volume = prototype( ("libvlc_audio_set_volume", dll), paramflags )
libvlc_audio_set_volume.__doc__ = """Set current audio level.
\param p_mi media player
\param i_volume the volume (int)
\return 0 if the volume was set, -1 if it was out of range
"""
if hasattr(dll, 'libvlc_audio_get_track_count'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, MediaPlayer)
paramflags=( (1, ), )
libvlc_audio_get_track_count = prototype( ("libvlc_audio_get_track_count", dll), paramflags )
libvlc_audio_get_track_count.__doc__ = """Get number of available audio tracks.
\param p_mi media player
\return the number of available audio tracks (int), or -1 if unavailable
"""
if hasattr(dll, 'libvlc_audio_get_track_description'):
prototype=ctypes.CFUNCTYPE(ctypes.POINTER(TrackDescription), MediaPlayer)
paramflags=( (1, ), )
libvlc_audio_get_track_description = prototype( ("libvlc_audio_get_track_description", dll), paramflags )
libvlc_audio_get_track_description.__doc__ = """Get the description of available audio tracks.
\param p_mi media player
\return list with description of available audio tracks, or NULL
"""
if hasattr(dll, 'libvlc_audio_get_track'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, MediaPlayer)
paramflags=( (1, ), )
libvlc_audio_get_track = prototype( ("libvlc_audio_get_track", dll), paramflags )
libvlc_audio_get_track.__doc__ = """Get current audio track.
\param p_mi media player
\return the audio track (int), or -1 if none.
"""
if hasattr(dll, 'libvlc_audio_set_track'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, MediaPlayer, ctypes.c_int)
paramflags=(1,), (1,)
libvlc_audio_set_track = prototype( ("libvlc_audio_set_track", dll), paramflags )
libvlc_audio_set_track.__doc__ = """Set current audio track.
\param p_mi media player
\param i_track the track (int)
\return 0 on success, -1 on error
"""
if hasattr(dll, 'libvlc_audio_get_channel'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, MediaPlayer)
paramflags=( (1, ), )
libvlc_audio_get_channel = prototype( ("libvlc_audio_get_channel", dll), paramflags )
libvlc_audio_get_channel.__doc__ = """Get current audio channel.
\param p_mi media player
\return the audio channel \see libvlc_audio_output_channel_t
"""
if hasattr(dll, 'libvlc_audio_set_channel'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, MediaPlayer, ctypes.c_int)
paramflags=(1,), (1,)
libvlc_audio_set_channel = prototype( ("libvlc_audio_set_channel", dll), paramflags )
libvlc_audio_set_channel.__doc__ = """Set current audio channel.
\param p_mi media player
\param channel the audio channel, \see libvlc_audio_output_channel_t
\return 0 on success, -1 on error
"""
if hasattr(dll, 'libvlc_audio_get_delay'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int64, MediaPlayer)
paramflags=( (1, ), )
libvlc_audio_get_delay = prototype( ("libvlc_audio_get_delay", dll), paramflags )
libvlc_audio_get_delay.__doc__ = """Get current audio delay.
\param p_mi media player
\return the audio delay (microseconds)
\version LibVLC 1.1.1 or later
"""
if hasattr(dll, 'libvlc_audio_set_delay'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, MediaPlayer, ctypes.c_int64)
paramflags=(1,), (1,)
libvlc_audio_set_delay = prototype( ("libvlc_audio_set_delay", dll), paramflags )
libvlc_audio_set_delay.__doc__ = """Set current audio delay. The audio delay will be reset to zero each time the media changes.
\param p_mi media player
\param i_delay the audio delay (microseconds)
\return 0 on success, -1 on error
\version LibVLC 1.1.1 or later
"""
if hasattr(dll, 'libvlc_vlm_release'):
prototype=ctypes.CFUNCTYPE(None, Instance)
paramflags=( (1, ), )
libvlc_vlm_release = prototype( ("libvlc_vlm_release", dll), paramflags )
libvlc_vlm_release.__doc__ = """Release the vlm instance related to the given libvlc_instance_t
\param p_instance the instance
"""
if hasattr(dll, 'libvlc_vlm_add_broadcast'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_int, ListPOINTER(ctypes.c_char_p), ctypes.c_int, ctypes.c_int)
paramflags=(1,), (1,), (1,), (1,), (1,), (1,), (1,), (1,)
libvlc_vlm_add_broadcast = prototype( ("libvlc_vlm_add_broadcast", dll), paramflags )
libvlc_vlm_add_broadcast.__doc__ = """Add a broadcast, with one input.
\param p_instance the instance
\param psz_name the name of the new broadcast
\param psz_input the input MRL
\param psz_output the output MRL (the parameter to the "sout" variable)
\param i_options number of additional options
\param ppsz_options additional options
\param b_enabled boolean for enabling the new broadcast
\param b_loop Should this broadcast be played in loop ?
\return 0 on success, -1 on error
"""
if hasattr(dll, 'libvlc_vlm_add_vod'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_int, ListPOINTER(ctypes.c_char_p), ctypes.c_int, ctypes.c_char_p)
paramflags=(1,), (1,), (1,), (1,), (1,), (1,), (1,)
libvlc_vlm_add_vod = prototype( ("libvlc_vlm_add_vod", dll), paramflags )
libvlc_vlm_add_vod.__doc__ = """Add a vod, with one input.
\param p_instance the instance
\param psz_name the name of the new vod media
\param psz_input the input MRL
\param i_options number of additional options
\param ppsz_options additional options
\param b_enabled boolean for enabling the new vod
\param psz_mux the muxer of the vod media
\return 0 on success, -1 on error
"""
if hasattr(dll, 'libvlc_vlm_del_media'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, Instance, ctypes.c_char_p)
paramflags=(1,), (1,)
libvlc_vlm_del_media = prototype( ("libvlc_vlm_del_media", dll), paramflags )
libvlc_vlm_del_media.__doc__ = """Delete a media (VOD or broadcast).
\param p_instance the instance
\param psz_name the media to delete
\return 0 on success, -1 on error
"""
if hasattr(dll, 'libvlc_vlm_set_enabled'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_int)
paramflags=(1,), (1,), (1,)
libvlc_vlm_set_enabled = prototype( ("libvlc_vlm_set_enabled", dll), paramflags )
libvlc_vlm_set_enabled.__doc__ = """Enable or disable a media (VOD or broadcast).
\param p_instance the instance
\param psz_name the media to work on
\param b_enabled the new status
\return 0 on success, -1 on error
"""
if hasattr(dll, 'libvlc_vlm_set_output'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_char_p)
paramflags=(1,), (1,), (1,)
libvlc_vlm_set_output = prototype( ("libvlc_vlm_set_output", dll), paramflags )
libvlc_vlm_set_output.__doc__ = """Set the output for a media.
\param p_instance the instance
\param psz_name the media to work on
\param psz_output the output MRL (the parameter to the "sout" variable)
\return 0 on success, -1 on error
"""
if hasattr(dll, 'libvlc_vlm_set_input'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_char_p)
paramflags=(1,), (1,), (1,)
libvlc_vlm_set_input = prototype( ("libvlc_vlm_set_input", dll), paramflags )
libvlc_vlm_set_input.__doc__ = """Set a media's input MRL. This will delete all existing inputs and
add the specified one.
\param p_instance the instance
\param psz_name the media to work on
\param psz_input the input MRL
\return 0 on success, -1 on error
"""
if hasattr(dll, 'libvlc_vlm_add_input'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_char_p)
paramflags=(1,), (1,), (1,)
libvlc_vlm_add_input = prototype( ("libvlc_vlm_add_input", dll), paramflags )
libvlc_vlm_add_input.__doc__ = """Add a media's input MRL. This will add the specified one.
\param p_instance the instance
\param psz_name the media to work on
\param psz_input the input MRL
\return 0 on success, -1 on error
"""
if hasattr(dll, 'libvlc_vlm_set_loop'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_int)
paramflags=(1,), (1,), (1,)
libvlc_vlm_set_loop = prototype( ("libvlc_vlm_set_loop", dll), paramflags )
libvlc_vlm_set_loop.__doc__ = """Set a media's loop status.
\param p_instance the instance
\param psz_name the media to work on
\param b_loop the new status
\return 0 on success, -1 on error
"""
if hasattr(dll, 'libvlc_vlm_set_mux'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_char_p)
paramflags=(1,), (1,), (1,)
libvlc_vlm_set_mux = prototype( ("libvlc_vlm_set_mux", dll), paramflags )
libvlc_vlm_set_mux.__doc__ = """Set a media's vod muxer.
\param p_instance the instance
\param psz_name the media to work on
\param psz_mux the new muxer
\return 0 on success, -1 on error
"""
if hasattr(dll, 'libvlc_vlm_change_media'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_int, ListPOINTER(ctypes.c_char_p), ctypes.c_int, ctypes.c_int)
paramflags=(1,), (1,), (1,), (1,), (1,), (1,), (1,), (1,)
libvlc_vlm_change_media = prototype( ("libvlc_vlm_change_media", dll), paramflags )
libvlc_vlm_change_media.__doc__ = """Edit the parameters of a media. This will delete all existing inputs and
add the specified one.
\param p_instance the instance
\param psz_name the name of the new broadcast
\param psz_input the input MRL
\param psz_output the output MRL (the parameter to the "sout" variable)
\param i_options number of additional options
\param ppsz_options additional options
\param b_enabled boolean for enabling the new broadcast
\param b_loop Should this broadcast be played in loop ?
\return 0 on success, -1 on error
"""
if hasattr(dll, 'libvlc_vlm_play_media'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, Instance, ctypes.c_char_p)
paramflags=(1,), (1,)
libvlc_vlm_play_media = prototype( ("libvlc_vlm_play_media", dll), paramflags )
libvlc_vlm_play_media.__doc__ = """Play the named broadcast.
\param p_instance the instance
\param psz_name the name of the broadcast
\return 0 on success, -1 on error
"""
if hasattr(dll, 'libvlc_vlm_stop_media'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, Instance, ctypes.c_char_p)
paramflags=(1,), (1,)
libvlc_vlm_stop_media = prototype( ("libvlc_vlm_stop_media", dll), paramflags )
libvlc_vlm_stop_media.__doc__ = """Stop the named broadcast.
\param p_instance the instance
\param psz_name the name of the broadcast
\return 0 on success, -1 on error
"""
if hasattr(dll, 'libvlc_vlm_pause_media'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, Instance, ctypes.c_char_p)
paramflags=(1,), (1,)
libvlc_vlm_pause_media = prototype( ("libvlc_vlm_pause_media", dll), paramflags )
libvlc_vlm_pause_media.__doc__ = """Pause the named broadcast.
\param p_instance the instance
\param psz_name the name of the broadcast
\return 0 on success, -1 on error
"""
if hasattr(dll, 'libvlc_vlm_seek_media'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_float)
paramflags=(1,), (1,), (1,)
libvlc_vlm_seek_media = prototype( ("libvlc_vlm_seek_media", dll), paramflags )
libvlc_vlm_seek_media.__doc__ = """Seek in the named broadcast.
\param p_instance the instance
\param psz_name the name of the broadcast
\param f_percentage the percentage to seek to
\return 0 on success, -1 on error
"""
if hasattr(dll, 'libvlc_vlm_show_media'):
prototype=ctypes.CFUNCTYPE(ctypes.c_char_p, Instance, ctypes.c_char_p)
paramflags=(1,), (1,)
libvlc_vlm_show_media = prototype( ("libvlc_vlm_show_media", dll), paramflags )
libvlc_vlm_show_media.__doc__ = """Return information about the named media as a JSON
string representation.
This function is mainly intended for debugging use,
if you want programmatic access to the state of
a vlm_media_instance_t, please use the corresponding
libvlc_vlm_get_media_instance_xxx -functions.
Currently there are no such functions available for
vlm_media_t though.
\param p_instance the instance
\param psz_name the name of the media,
if the name is an empty string, all media is described
\return string with information about named media, or NULL on error
"""
if hasattr(dll, 'libvlc_vlm_get_media_instance_position'):
prototype=ctypes.CFUNCTYPE(ctypes.c_float, Instance, ctypes.c_char_p, ctypes.c_int)
paramflags=(1,), (1,), (1,)
libvlc_vlm_get_media_instance_position = prototype( ("libvlc_vlm_get_media_instance_position", dll), paramflags )
libvlc_vlm_get_media_instance_position.__doc__ = """Get vlm_media instance position by name or instance id
\param p_instance a libvlc instance
\param psz_name name of vlm media instance
\param i_instance instance id
\return position as float or -1. on error
"""
if hasattr(dll, 'libvlc_vlm_get_media_instance_time'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_int)
paramflags=(1,), (1,), (1,)
libvlc_vlm_get_media_instance_time = prototype( ("libvlc_vlm_get_media_instance_time", dll), paramflags )
libvlc_vlm_get_media_instance_time.__doc__ = """Get vlm_media instance time by name or instance id
\param p_instance a libvlc instance
\param psz_name name of vlm media instance
\param i_instance instance id
\return time as integer or -1 on error
"""
if hasattr(dll, 'libvlc_vlm_get_media_instance_length'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_int)
paramflags=(1,), (1,), (1,)
libvlc_vlm_get_media_instance_length = prototype( ("libvlc_vlm_get_media_instance_length", dll), paramflags )
libvlc_vlm_get_media_instance_length.__doc__ = """Get vlm_media instance length by name or instance id
\param p_instance a libvlc instance
\param psz_name name of vlm media instance
\param i_instance instance id
\return length of media item or -1 on error
"""
if hasattr(dll, 'libvlc_vlm_get_media_instance_rate'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_int)
paramflags=(1,), (1,), (1,)
libvlc_vlm_get_media_instance_rate = prototype( ("libvlc_vlm_get_media_instance_rate", dll), paramflags )
libvlc_vlm_get_media_instance_rate.__doc__ = """Get vlm_media instance playback rate by name or instance id
\param p_instance a libvlc instance
\param psz_name name of vlm media instance
\param i_instance instance id
\return playback rate or -1 on error
"""
if hasattr(dll, 'libvlc_vlm_get_media_instance_title'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_int)
paramflags=(1,), (1,), (1,)
libvlc_vlm_get_media_instance_title = prototype( ("libvlc_vlm_get_media_instance_title", dll), paramflags )
libvlc_vlm_get_media_instance_title.__doc__ = """Get vlm_media instance title number by name or instance id
\bug will always return 0
\param p_instance a libvlc instance
\param psz_name name of vlm media instance
\param i_instance instance id
\return title as number or -1 on error
"""
if hasattr(dll, 'libvlc_vlm_get_media_instance_chapter'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_int)
paramflags=(1,), (1,), (1,)
libvlc_vlm_get_media_instance_chapter = prototype( ("libvlc_vlm_get_media_instance_chapter", dll), paramflags )
libvlc_vlm_get_media_instance_chapter.__doc__ = """Get vlm_media instance chapter number by name or instance id
\bug will always return 0
\param p_instance a libvlc instance
\param psz_name name of vlm media instance
\param i_instance instance id
\return chapter as number or -1 on error
"""
if hasattr(dll, 'libvlc_vlm_get_media_instance_seekable'):
prototype=ctypes.CFUNCTYPE(ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_int)
paramflags=(1,), (1,), (1,)
libvlc_vlm_get_media_instance_seekable = prototype( ("libvlc_vlm_get_media_instance_seekable", dll), paramflags )
libvlc_vlm_get_media_instance_seekable.__doc__ = """Is libvlc instance seekable ?
\bug will always return 0
\param p_instance a libvlc instance
\param psz_name name of vlm media instance
\param i_instance instance id
\return 1 if seekable, 0 if not, -1 if media does not exist
"""
if hasattr(dll, 'libvlc_vlm_get_event_manager'):
prototype=ctypes.CFUNCTYPE(EventManager, Instance)
paramflags=( (1, ), )
libvlc_vlm_get_event_manager = prototype( ("libvlc_vlm_get_event_manager", dll), paramflags )
libvlc_vlm_get_event_manager.__doc__ = """Get libvlc_event_manager from a vlm media.
The p_event_manager is immutable, so you don't have to hold the lock
\param p_instance a libvlc instance
\return libvlc_event_manager
"""
### Start of footer.py ###
class MediaEvent(ctypes.Structure):
_fields_ = [
('media_name', ctypes.c_char_p),
('instance_name', ctypes.c_char_p),
]
class EventUnion(ctypes.Union):
_fields_ = [
('meta_type', ctypes.c_uint),
('new_child', ctypes.c_uint),
('new_duration', ctypes.c_longlong),
('new_status', ctypes.c_int),
('media', ctypes.c_void_p),
('new_state', ctypes.c_uint),
# Media instance
('new_position', ctypes.c_float),
('new_time', ctypes.c_longlong),
('new_title', ctypes.c_int),
('new_seekable', ctypes.c_longlong),
('new_pausable', ctypes.c_longlong),
# FIXME: Skipped MediaList and MediaListView...
('filename', ctypes.c_char_p),
('new_length', ctypes.c_longlong),
('media_event', MediaEvent),
]
class Event(ctypes.Structure):
_fields_ = [
('type', EventType),
('object', ctypes.c_void_p),
('u', EventUnion),
]
# Decorator for callback methods
callbackmethod=ctypes.CFUNCTYPE(None, ctypes.POINTER(Event), ctypes.c_void_p)
# Example callback method
@callbackmethod
def debug_callback(event, data):
print "Debug callback method"
print "Event:", event.contents.type
print "Data", data
if __name__ == '__main__':
try:
from msvcrt import getch
except ImportError:
def getch():
import tty
import termios
fd=sys.stdin.fileno()
old_settings=termios.tcgetattr(fd)
try:
tty.setraw(fd)
ch=sys.stdin.read(1)
finally:
termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
return ch
@callbackmethod
def end_callback(event, data):
print "End of stream"
sys.exit(0)
if sys.argv[1:]:
instance=Instance()
media=instance.media_new(sys.argv[1])
player=instance.media_player_new()
player.set_media(media)
player.play()
event_manager=player.event_manager()
event_manager.event_attach(EventType.MediaPlayerEndReached, end_callback, None)
def print_info():
"""Print information about the media."""
media=player.get_media()
print "State:", player.get_state()
print "Media:", media.get_mrl()
try:
print "Current time:", player.get_time(), "/", media.get_duration()
print "Position:", player.get_position()
print "FPS:", player.get_fps()
print "Rate:", player.get_rate()
print "Video size: (%d, %d)" % (player.video_get_width(), player.video_get_height())
except Exception:
pass
def forward():
"""Go forward 1s"""
player.set_time(player.get_time() + 1000)
def one_frame_forward():
"""Go forward one frame"""
player.set_time(player.get_time() + long(1000 / (player.get_fps() or 25)))
def one_frame_backward():
"""Go backward one frame"""
player.set_time(player.get_time() - long(1000 / (player.get_fps() or 25)))
def backward():
"""Go backward 1s"""
player.set_time(player.get_time() - 1000)
def print_help():
"""Print help
"""
print "Commands:"
for k, m in keybindings.iteritems():
print " %s: %s" % (k, (m.__doc__ or m.__name__).splitlines()[0])
print " 1-9: go to the given fraction of the movie"
def quit_app():
"""Exit."""
sys.exit(0)
keybindings={
'f': player.toggle_fullscreen,
' ': player.pause,
'+': forward,
'-': backward,
'.': one_frame_forward,
',': one_frame_backward,
'?': print_help,
'i': print_info,
'q': quit_app,
}
print "Press q to quit, ? to get help."
while True:
k=getch()
o=ord(k)
method=keybindings.get(k, None)
if method is not None:
method()
elif o >= 49 and o <= 57:
# Numeric value. Jump to a fraction of the movie.
v=0.1*(o-48)
player.set_position(v)
else:
print "Syntax: %s movie_filename" % sys.argv[0]
print "Once launched, type ? to get commands."
# Not wrapped methods:
# libvlc_get_version
# libvlc_set_exit_handler
# libvlc_get_changeset
# libvlc_errmsg
# libvlc_audio_output_list_release
# libvlc_clearerr
# libvlc_track_description_release
# libvlc_video_set_callbacks
# libvlc_get_compiler
# libvlc_new
# libvlc_event_type_name
| 40.625242 | 177 | 0.71597 | 29,241 | 209,545 | 4.840874 | 0.039944 | 0.058282 | 0.03569 | 0.053535 | 0.83772 | 0.763041 | 0.678895 | 0.612842 | 0.533119 | 0.486231 | 0 | 0.007959 | 0.191744 | 209,545 | 5,157 | 178 | 40.63312 | 0.827817 | 0.008833 | 0 | 0.476204 | 0 | 0.001154 | 0.366863 | 0.111112 | 0 | 0 | 0.000356 | 0.000388 | 0 | 0 | null | null | 0.001731 | 0.003173 | null | null | 0.006057 | 0 | 0 | 0 | null | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
6c6ef371f75559ac2ae1cc686771a714889b6a4a | 580 | py | Python | json_default.py | funkybob/json_default | 902cee5d3300228c3ae6accf8a6644702064b82f | [
"MIT"
] | 6 | 2017-10-27T23:08:45.000Z | 2020-10-27T12:16:32.000Z | json_default.py | funkybob/json_default | 902cee5d3300228c3ae6accf8a6644702064b82f | [
"MIT"
] | null | null | null | json_default.py | funkybob/json_default | 902cee5d3300228c3ae6accf8a6644702064b82f | [
"MIT"
] | null | null | null |
'''
Implementaion of the ideas from https://hynek.me/articles/serialization/
'''
import datetime
from functools import singledispatch
__version__ = '0.2'
@singledispatch
def default(obj):
'''Safe and sane default'''
return str(obj)
@default.register(datetime.datetime)
def _(obj):
r = obj.replace(microsecond=0).isoformat()
if r.endswith('+00:00'):
r = r[:-6] + 'Z'
return r
@default.register(datetime.date)
def _(obj):
return obj.isoformat()
@default.register(datetime.time)
def _(obj):
return obj.replace(microsecond=0).isoformat()
| 17.575758 | 72 | 0.682759 | 74 | 580 | 5.256757 | 0.5 | 0.115681 | 0.177378 | 0.113111 | 0.159383 | 0 | 0 | 0 | 0 | 0 | 0 | 0.018634 | 0.167241 | 580 | 32 | 73 | 18.125 | 0.786749 | 0.162069 | 0 | 0.166667 | 0 | 0 | 0.021186 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.222222 | false | 0 | 0.111111 | 0.111111 | 0.555556 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
6c718e5bd0418c32775584efd5c378733b050828 | 1,011 | py | Python | tests/python/unittest/test_autotvm_dispatch_context.py | titikid/tvm | 0cf3765b28d457d2503ec20b551e9a8eadb1491d | [
"Apache-2.0"
] | 1 | 2020-12-30T02:48:44.000Z | 2020-12-30T02:48:44.000Z | tests/python/unittest/test_autotvm_dispatch_context.py | titikid/tvm | 0cf3765b28d457d2503ec20b551e9a8eadb1491d | [
"Apache-2.0"
] | null | null | null | tests/python/unittest/test_autotvm_dispatch_context.py | titikid/tvm | 0cf3765b28d457d2503ec20b551e9a8eadb1491d | [
"Apache-2.0"
] | 1 | 2018-11-25T19:35:25.000Z | 2018-11-25T19:35:25.000Z | """Test dispatcher.
The dispatcher can choose which template to use according
to the parameters of workload"""
from collections import namedtuple
from tvm.autotvm.task import dispatcher, DispatchContext
SimpleWorkload = namedtuple("SimpleWorkload", ["key"])
SimpleConfig = namedtuple("SimpleConfig", ["template_key"])
def test_dispatch():
@dispatcher
def my_dispatcher(a, b):
return SimpleWorkload(key=a + b)
@my_dispatcher.register("spatial_pack")
def _sp_pack_add(cfg, a, b):
return b + 100
@my_dispatcher.register("im2col")
def _im2col_add(cfg, a, b):
return a + 1
class SimpleDispatcher(DispatchContext):
def query(self, target, workload):
tkey = "spatial_pack" if workload.key > 2 else "im2col"
return SimpleConfig(tkey)
with SimpleDispatcher():
# im2col
assert my_dispatcher(1, 0) == 2
# spack
assert my_dispatcher(1, 100) == 200
if __name__ == "__main__":
test_dispatch()
| 27.324324 | 67 | 0.667656 | 119 | 1,011 | 5.478992 | 0.462185 | 0.092025 | 0.03681 | 0.02454 | 0.042945 | 0 | 0 | 0 | 0 | 0 | 0 | 0.024359 | 0.228487 | 1,011 | 36 | 68 | 28.083333 | 0.811538 | 0.116716 | 0 | 0 | 0 | 0 | 0.095937 | 0 | 0 | 0 | 0 | 0 | 0.086957 | 1 | 0.217391 | false | 0 | 0.086957 | 0.130435 | 0.521739 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
6c7b9fc32923c58a6f94af313b5910427d04922d | 189 | py | Python | fastapi_auth/fastapi_util/settings/base_api_settings.py | dmontagu/fastapi-auth | d0e86774f66bd43e80376de19bdf034eb228dc07 | [
"MIT"
] | 87 | 2019-12-18T05:43:25.000Z | 2022-03-30T20:04:11.000Z | fastapi_auth/fastapi_util/settings/base_api_settings.py | dmontagu/fastapi-auth | d0e86774f66bd43e80376de19bdf034eb228dc07 | [
"MIT"
] | 2 | 2020-08-07T05:17:18.000Z | 2021-09-14T03:20:04.000Z | fastapi_auth/fastapi_util/settings/base_api_settings.py | dmontagu/fastapi-auth | d0e86774f66bd43e80376de19bdf034eb228dc07 | [
"MIT"
] | 7 | 2020-03-08T17:14:33.000Z | 2022-01-01T21:38:47.000Z | from pydantic import BaseSettings
class BaseAPISettings(BaseSettings):
class Config:
env_prefix = ""
arbitrary_types_allowed = True
validate_assignment = True
| 21 | 38 | 0.703704 | 18 | 189 | 7.166667 | 0.833333 | 0.263566 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.248677 | 189 | 8 | 39 | 23.625 | 0.908451 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.166667 | 0 | 0.5 | 0 | 1 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
6664d8ef0b4838070d4bda1fe96c2e05c7dd28f6 | 632 | py | Python | py/pyfeng/ex.py | AHrmnd/ASP-1 | 097ebf0a6a84ce2c8078026f0da8e930ff74d613 | [
"MIT"
] | null | null | null | py/pyfeng/ex.py | AHrmnd/ASP-1 | 097ebf0a6a84ce2c8078026f0da8e930ff74d613 | [
"MIT"
] | null | null | null | py/pyfeng/ex.py | AHrmnd/ASP-1 | 097ebf0a6a84ce2c8078026f0da8e930ff74d613 | [
"MIT"
] | null | null | null | #from .heston_fft import HestonFft
# SV models (CMC, AE) from ASP 2021
from .heston_mc import HestonMcAndersen2008, HestonMcGlassermanKim2011, HestonMcTseWan2013, HestonMcChoiKwok2023
from .sv32_mc import Sv32McCondQE, Sv32McAe
from .garch import GarchMcTimeStep, GarchUncorrBaroneAdesi2004
# SABR / OUSV models for research
from .sabr_int import SabrCondQuad
from .sabr_mc import SabrMcExactCai2017
from .ousv import OusvSchobelZhu1998, OusvMcTimeStep, OusvMcChoi2023
# Basket-Asian from ASP 2021
from .multiasset_Ju2002 import BsmBasketAsianJu2002, BsmContinuousAsianJu2002
from .asian import BsmAsianLinetsky2004, BsmAsianJsu
| 39.5 | 112 | 0.849684 | 68 | 632 | 7.808824 | 0.588235 | 0.045198 | 0.041431 | 0.056497 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.109929 | 0.107595 | 632 | 15 | 113 | 42.133333 | 0.83156 | 0.199367 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
66699c32300a5578cde7d2ac9bcaae6ecc31ab41 | 166 | py | Python | tests/forms_tests/urls.py | peteralexandercharles/django | 61c7350f41f2534daf3888709f3c987b7d779a29 | [
"BSD-3-Clause",
"0BSD"
] | null | null | null | tests/forms_tests/urls.py | peteralexandercharles/django | 61c7350f41f2534daf3888709f3c987b7d779a29 | [
"BSD-3-Clause",
"0BSD"
] | null | null | null | tests/forms_tests/urls.py | peteralexandercharles/django | 61c7350f41f2534daf3888709f3c987b7d779a29 | [
"BSD-3-Clause",
"0BSD"
] | null | null | null | from django.urls import path
from .views import ArticleFormView
urlpatterns = [
path("model_form/<int:pk>/", ArticleFormView.as_view(), name="article_form"),
]
| 20.75 | 81 | 0.73494 | 21 | 166 | 5.666667 | 0.761905 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.126506 | 166 | 7 | 82 | 23.714286 | 0.82069 | 0 | 0 | 0 | 0 | 0 | 0.192771 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.4 | 0 | 0.4 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
6683c6da0989248a5c9aa79f3215b523dbbd5a69 | 213 | py | Python | agent/random_agent.py | Kulbear/endless-2048 | 939479e6ae5d4dae6fb636c9803f8d4ebf5be0e8 | [
"MIT"
] | 11 | 2017-05-14T19:29:56.000Z | 2020-05-24T07:02:03.000Z | agent/random_agent.py | Kulbear/endless-2048 | 939479e6ae5d4dae6fb636c9803f8d4ebf5be0e8 | [
"MIT"
] | null | null | null | agent/random_agent.py | Kulbear/endless-2048 | 939479e6ae5d4dae6fb636c9803f8d4ebf5be0e8 | [
"MIT"
] | 7 | 2017-07-08T05:54:55.000Z | 2021-11-13T14:01:39.000Z | from .base_agent import BaseAgent
from random import choice
class RandomAgent(BaseAgent):
"""A game agent pick the next move randomly."""
def get_move(self, game):
return self.random_move(game)
| 21.3 | 51 | 0.71831 | 30 | 213 | 5 | 0.666667 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.197183 | 213 | 9 | 52 | 23.666667 | 0.877193 | 0.192488 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.2 | false | 0 | 0.4 | 0.2 | 1 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 3 |
66888596c077828cae5b9fd6ce3053cfae609913 | 579 | py | Python | my_puzzle_example.py | ddurler/water_sort_puzzle | 6f605f52ba63c74908f7e28cee4c850724c67dc6 | [
"MIT"
] | null | null | null | my_puzzle_example.py | ddurler/water_sort_puzzle | 6f605f52ba63c74908f7e28cee4c850724c67dc6 | [
"MIT"
] | null | null | null | my_puzzle_example.py | ddurler/water_sort_puzzle | 6f605f52ba63c74908f7e28cee4c850724c67dc6 | [
"MIT"
] | null | null | null | """
Puzzle resolution example.
See README.md file.
"""
# Import required modules
from bottle import Bottle
from puzzle import Puzzle
from puzzle_solver import solve_generic
"""
Puzzle to be solved in this example:
| R | | | | V | | |
| R | | | | V | | |
| B | | R | | B | | V |
| B | | R | | B | | V |
----- ----- ----- -----
(1) (2) (3) (4)
"""
puzzle: Puzzle = Puzzle([Bottle("BBRR"), Bottle("RR"), Bottle("BBVV"), Bottle("VV")])
# Solving
solve_generic(puzzle)
| 23.16 | 85 | 0.455959 | 62 | 579 | 4.209677 | 0.516129 | 0.076628 | 0.137931 | 0.030651 | 0.034483 | 0 | 0 | 0 | 0 | 0 | 0 | 0.01084 | 0.362694 | 579 | 24 | 86 | 24.125 | 0.696477 | 0.136442 | 0 | 0 | 0 | 0 | 0.057971 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.6 | 0 | 0.6 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
668efd1205224a92c1d3ed11647276739d0a85ab | 278 | py | Python | scikits/statsmodels/stats/__init__.py | matthew-brett/statsmodels | 915c9dc2d762c5592ac17a7cf5f1cc957fcbde1c | [
"BSD-3-Clause"
] | null | null | null | scikits/statsmodels/stats/__init__.py | matthew-brett/statsmodels | 915c9dc2d762c5592ac17a7cf5f1cc957fcbde1c | [
"BSD-3-Clause"
] | null | null | null | scikits/statsmodels/stats/__init__.py | matthew-brett/statsmodels | 915c9dc2d762c5592ac17a7cf5f1cc957fcbde1c | [
"BSD-3-Clause"
] | null | null | null | #collect some imports of verified (at least one example) functions
from scikits.statsmodels.sandbox.stats.multicomp import \
multipletests, fdrcorrection0, fdrcorrection_twostage, tukeyhsd
from scikits.statsmodels import NoseWrapper as Tester
test = Tester().test
| 39.714286 | 76 | 0.794964 | 32 | 278 | 6.875 | 0.8125 | 0.1 | 0.2 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.004219 | 0.147482 | 278 | 6 | 77 | 46.333333 | 0.924051 | 0.233813 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.5 | 0 | 0.5 | 0 | 0 | 0 | 0 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
66a99f3ad85666bf30241b2c6c9efc6f2618eb8a | 438 | py | Python | ezread3.py | eigencode/Caerus | cb00635767b38665f20220699cbe2a2d10aae9ed | [
"Apache-2.0"
] | null | null | null | ezread3.py | eigencode/Caerus | cb00635767b38665f20220699cbe2a2d10aae9ed | [
"Apache-2.0"
] | null | null | null | ezread3.py | eigencode/Caerus | cb00635767b38665f20220699cbe2a2d10aae9ed | [
"Apache-2.0"
] | null | null | null | #!/system/xbin/env python3
#!/system/xbin/env python3
import fileinput
import re
while True
S = fileinput.input():
S =
datalist = ["[" + S.rstrip() + "]\n" for S in fileinput.input() if not re.match("\s*\n",S) ]
print(*datalist)
#!/system/xbin/env python3
import io
import sys
import codecs
import win_unicode_console
win_unicode_console.enable()
for s in sys.argv:
print(type(s))
print(s)
read arguments
| 19.043478 | 94 | 0.66895 | 66 | 438 | 4.378788 | 0.469697 | 0.103806 | 0.134948 | 0.207612 | 0.179931 | 0 | 0 | 0 | 0 | 0 | 0 | 0.008451 | 0.189498 | 438 | 22 | 95 | 19.909091 | 0.805634 | 0.171233 | 0 | 0 | 0 | 0 | 0.026706 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0.375 | null | null | 0.1875 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
66afdd63c1ea7ed5098b7bf57c98d2bda9430295 | 236 | py | Python | tests/turtle.py | hitmeet5/free-python-games | d703890e516d8bb66b74a37061644335683e84c8 | [
"Apache-2.0"
] | null | null | null | tests/turtle.py | hitmeet5/free-python-games | d703890e516d8bb66b74a37061644335683e84c8 | [
"Apache-2.0"
] | null | null | null | tests/turtle.py | hitmeet5/free-python-games | d703890e516d8bb66b74a37061644335683e84c8 | [
"Apache-2.0"
] | 1 | 2020-11-04T02:51:57.000Z | 2020-11-04T02:51:57.000Z | """Mock turtle module.
"""
def goto(x, y):
pass
def up():
pass
def down():
pass
def color(name):
pass
def begin_fill():
pass
def end_fill():
pass
def forward(steps):
pass
def left(degrees):
pass
| 8.428571 | 22 | 0.567797 | 34 | 236 | 3.882353 | 0.558824 | 0.371212 | 0.166667 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.29661 | 236 | 27 | 23 | 8.740741 | 0.795181 | 0.080508 | 0 | 0.5 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.5 | false | 0.5 | 0 | 0 | 0.5 | 0 | 0 | 0 | 0 | null | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 3 |
66cf04b63104a48786b822a338c359c28bb42a45 | 363 | py | Python | LabelExpressions/labelExpression.py | cdflint/arcpy-wizardry | bb9b68305bfdb3812ae951c49fc37d2eb29cf237 | [
"Apache-2.0"
] | 1 | 2017-07-17T20:13:19.000Z | 2017-07-17T20:13:19.000Z | LabelExpressions/labelExpression.py | cdflint/arcpy-wizardry | bb9b68305bfdb3812ae951c49fc37d2eb29cf237 | [
"Apache-2.0"
] | null | null | null | LabelExpressions/labelExpression.py | cdflint/arcpy-wizardry | bb9b68305bfdb3812ae951c49fc37d2eb29cf237 | [
"Apache-2.0"
] | null | null | null | # Define a custom python label expression that will
# Take three fields NAME,LASTCENSUS and POP_EST and
# will return a custom formatted text blob with a Bolded NAME and Red census pop
def FindLabel ([NAME],[LASTCENSUS],[POP_EST]):
label = "<BOL>{0}</BOL>\n{1} Census:\n<CLR red = '255'>{2:,}</CLR>".format([NAME],[LASTCENSUS],int([POP_EST]))
return label | 60.5 | 114 | 0.705234 | 59 | 363 | 4.288136 | 0.59322 | 0.166008 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.019293 | 0.143251 | 363 | 6 | 115 | 60.5 | 0.794212 | 0.490358 | 0 | 0 | 0 | 0.333333 | 0.313187 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0 | null | null | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
66d0b97dc43ff1c867e1ace5a43de89c532726bc | 1,588 | py | Python | python/experiments/latest/tools/mention.py | boyuanzheng010/friends_semeval | 7891d072fd2598374e4bc1af6a9febed2577e118 | [
"Apache-2.0"
] | 39 | 2017-04-21T00:19:31.000Z | 2022-03-07T21:37:55.000Z | python/experiments/latest/tools/mention.py | BarryZM/character-identification | 5c47347aeff7ff8a16460b6f38637bc47a2efa1b | [
"Apache-2.0"
] | 1 | 2020-07-05T11:22:31.000Z | 2021-02-25T12:04:56.000Z | python/experiments/latest/tools/mention.py | BarryZM/character-identification | 5c47347aeff7ff8a16460b6f38637bc47a2efa1b | [
"Apache-2.0"
] | 8 | 2018-05-11T06:55:24.000Z | 2020-07-15T20:53:28.000Z | import numpy as np
from structure import TokenNode
class PluralMentionNode(object):
def __init__(self, id, tokens, gold_refs, auto_refs=None, feat_map=None, plural=False):
self.id = id
self.tokens = tokens
self.gold_refs = [gref.lower() for gref in gold_refs]
self.auto_refs = [aref.lower() for aref in auto_refs] if auto_refs else []
self.feat_map = feat_map if feat_map is not None else dict()
self.plural = plural
def __lt__(self, other_mention):
return self.id < other_mention.id
def __gt__(self, other_mention):
return other_mention.__lt__(self)
def __str__(self):
return " ".join(map(str, self.tokens)) + " %d" % self.id
def __repr__(self):
return self.__str__()
def is_other(self):
return True if self.id == -1 and self.gold_refs == ["#other#"] else False
def is_general(self):
return True if self.id == -1 and self.gold_refs == ["#general#"] else False
other = PluralMentionNode(-1, [TokenNode(-1, "#other#")], ["#other#"], feat_map={})
general = PluralMentionNode(-1, [TokenNode(-1, "#general#")], ["#general#"], feat_map={})
def init_super_mentions(eftdims, mftdim, pftdim):
other.feat_map["efts"] = [np.random.rand(d1, d2) for d1, d2 in eftdims]
other.feat_map["mft"] = np.random.rand(mftdim)
other.feat_map["pft"] = np.random.rand(pftdim)
general.feat_map["efts"] = [np.random.rand(d1, d2) for d1, d2 in eftdims]
general.feat_map["mft"] = np.random.rand(mftdim)
general.feat_map["pft"] = np.random.rand(pftdim)
| 32.408163 | 91 | 0.647985 | 230 | 1,588 | 4.226087 | 0.252174 | 0.08642 | 0.074074 | 0.045267 | 0.281893 | 0.281893 | 0.281893 | 0.166667 | 0.166667 | 0.166667 | 0 | 0.011067 | 0.203401 | 1,588 | 48 | 92 | 33.083333 | 0.757312 | 0 | 0 | 0 | 0 | 0 | 0.04534 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.258065 | false | 0 | 0.064516 | 0.193548 | 0.548387 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
66da55db88808c4a30877d7685e7dea2973e89d2 | 1,031 | py | Python | slurp/plugin_types.py | iksteen/slurp | 751ef1ee15fbb2a928661ae4e94888c7fdd6d11a | [
"MIT"
] | 1 | 2020-02-26T14:40:11.000Z | 2020-02-26T14:40:11.000Z | slurp/plugin_types.py | iksteen/slurp | 751ef1ee15fbb2a928661ae4e94888c7fdd6d11a | [
"MIT"
] | null | null | null | slurp/plugin_types.py | iksteen/slurp | 751ef1ee15fbb2a928661ae4e94888c7fdd6d11a | [
"MIT"
] | null | null | null | from abc import ABCMeta, abstractmethod
class Plugin(metaclass=ABCMeta):
@abstractmethod
def __init__(self, core, *, loop=None):
...
@abstractmethod
async def start(self):
...
@abstractmethod
async def run(self):
...
class BackendPlugin(Plugin):
pass
class MetadataPlugin(Plugin, metaclass=ABCMeta):
@abstractmethod
async def enrich(self, backlog_item):
...
class SearchPlugin(Plugin, metaclass=ABCMeta):
@abstractmethod
async def search(self, backlog_item):
...
class DownloadPlugin(Plugin, metaclass=ABCMeta):
@abstractmethod
def is_downloading(self, backlog_item):
...
@abstractmethod
async def download(self, backlog_item, data):
...
class PreProcessingPlugin(Plugin, metaclass=ABCMeta):
@abstractmethod
async def process(self, files):
...
class PostProcessingPlugin(Plugin, metaclass=ABCMeta):
@abstractmethod
async def process(self, episodes_info, files):
...
| 19.092593 | 54 | 0.657614 | 98 | 1,031 | 6.816327 | 0.367347 | 0.22006 | 0.230539 | 0.323353 | 0.413174 | 0.296407 | 0.164671 | 0.164671 | 0 | 0 | 0 | 0 | 0.236663 | 1,031 | 53 | 55 | 19.45283 | 0.848793 | 0 | 0 | 0.5 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.055556 | false | 0.027778 | 0.027778 | 0 | 0.277778 | 0 | 0 | 0 | 0 | null | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
dd00cd295c94c712ac16eb0b68703b881398ede0 | 171 | py | Python | script/simple_html_strip.py | jdsayle/scripts | 46e7e2e37dde74c6b2b10474c7fb6cb6bdb6921c | [
"MIT"
] | null | null | null | script/simple_html_strip.py | jdsayle/scripts | 46e7e2e37dde74c6b2b10474c7fb6cb6bdb6921c | [
"MIT"
] | null | null | null | script/simple_html_strip.py | jdsayle/scripts | 46e7e2e37dde74c6b2b10474c7fb6cb6bdb6921c | [
"MIT"
] | null | null | null | import re
import fileinput
# change NAME_OF_FILE to local file
for line in fileinput.input(['NAME_OF_FILE'], inplace=True):
print(re.sub(r'<.*?>', '', line), end='')
| 24.428571 | 60 | 0.678363 | 27 | 171 | 4.148148 | 0.703704 | 0.107143 | 0.178571 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.140351 | 171 | 6 | 61 | 28.5 | 0.761905 | 0.192982 | 0 | 0 | 0 | 0 | 0.125 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.5 | 0 | 0.5 | 0.25 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
dd1650a94d7ab60eebe5b9f57471176d217c1ac9 | 231 | py | Python | lang/py/pylib/12/urlparse_urljoin_v2.py | ch1huizong/learning | 632267634a9fd84a5f5116de09ff1e2681a6cc85 | [
"MIT"
] | null | null | null | lang/py/pylib/12/urlparse_urljoin_v2.py | ch1huizong/learning | 632267634a9fd84a5f5116de09ff1e2681a6cc85 | [
"MIT"
] | null | null | null | lang/py/pylib/12/urlparse_urljoin_v2.py | ch1huizong/learning | 632267634a9fd84a5f5116de09ff1e2681a6cc85 | [
"MIT"
] | null | null | null | #!/usr/bin/env python
from urlparse import urljoin
print urljoin('http://www.example.com/path/',
'/subpath/file.html')
print urljoin('http://www.example.com/path/file.html',
'subpath/file.html')
| 21 | 54 | 0.623377 | 30 | 231 | 4.8 | 0.566667 | 0.166667 | 0.222222 | 0.263889 | 0.458333 | 0.458333 | 0.458333 | 0 | 0 | 0 | 0 | 0 | 0.207792 | 231 | 10 | 55 | 23.1 | 0.786885 | 0.08658 | 0 | 0 | 0 | 0 | 0.478469 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | null | 0 | 0.2 | null | null | 0.4 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
dd3598c5214f8669b745a590619f7c18967e7e18 | 58 | py | Python | backend/apps/projects/case/__init__.py | wuchaofan1654/tester | ff38d42e06cbdfa04882e8e95ada2dd93e6609f2 | [
"MIT"
] | null | null | null | backend/apps/projects/case/__init__.py | wuchaofan1654/tester | ff38d42e06cbdfa04882e8e95ada2dd93e6609f2 | [
"MIT"
] | null | null | null | backend/apps/projects/case/__init__.py | wuchaofan1654/tester | ff38d42e06cbdfa04882e8e95ada2dd93e6609f2 | [
"MIT"
] | null | null | null | default_app_config = 'apps.projects.case.apps.CaseConfig'
| 29 | 57 | 0.827586 | 8 | 58 | 5.75 | 0.875 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.051724 | 58 | 1 | 58 | 58 | 0.836364 | 0 | 0 | 0 | 0 | 0 | 0.586207 | 0.586207 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
dd48bba9c909dc7ba3f87f97833446de2f2d71be | 239 | py | Python | tflib/step.py | relaxdiego/auto | c850fad817f9f1bf8286897ff5f4eae09c37a752 | [
"Apache-2.0"
] | null | null | null | tflib/step.py | relaxdiego/auto | c850fad817f9f1bf8286897ff5f4eae09c37a752 | [
"Apache-2.0"
] | null | null | null | tflib/step.py | relaxdiego/auto | c850fad817f9f1bf8286897ff5f4eae09c37a752 | [
"Apache-2.0"
] | null | null | null | from tflib.mixins.loggable import LoggableMixin
class Step(object, LoggableMixin):
def get_expectation(self, name):
return getattr(self, "%s_expectation" % name)
def undo(self):
self.log.info("Nothing to undo")
| 21.727273 | 53 | 0.690377 | 30 | 239 | 5.433333 | 0.733333 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.200837 | 239 | 10 | 54 | 23.9 | 0.853403 | 0 | 0 | 0 | 0 | 0 | 0.121339 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.333333 | false | 0 | 0.166667 | 0.166667 | 0.833333 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
dd5085fd3e392e39b89683504a5aed2054cfa631 | 2,704 | py | Python | src/web/PaginaWeb/General/models.py | madscientist98/Berserk-Project | 9336f6893a071b52fa45c057a34bc84217ecdb41 | [
"MIT"
] | null | null | null | src/web/PaginaWeb/General/models.py | madscientist98/Berserk-Project | 9336f6893a071b52fa45c057a34bc84217ecdb41 | [
"MIT"
] | null | null | null | src/web/PaginaWeb/General/models.py | madscientist98/Berserk-Project | 9336f6893a071b52fa45c057a34bc84217ecdb41 | [
"MIT"
] | null | null | null | from django.db import models
from django.contrib.auth.models import User
from django.db.models.signals import post_save
# Create your models here.
class Usuario(models.Model):
username = models.CharField(max_length=100, default='',unique = True)
password = models.CharField(max_length=100, default='')
cash = models.IntegerField(default=0)
pais = models.CharField(max_length=100,default='Peru')
def __str__(self):
return self.username
class Personaje(models.Model):
id_usuario = models.ForeignKey(Usuario, on_delete=models.CASCADE)
velocidad_movimiento = models.DecimalField(max_digits=3, decimal_places=2)
aceleracion = models.DecimalField(max_digits=2, decimal_places=2)
vida = models.IntegerField(default = '100')
defensa = models.IntegerField(default = '0')
damage_ataque_basico = models.IntegerField(default = '5')
salto = models.DecimalField(max_digits=1, decimal_places=1)
velocidad_ataque = models.DecimalField(max_digits=2, decimal_places=2)
estado = models.IntegerField(default='0')
def __str__(self):
return self.vida + "\t" + self.defensa
class Mago(models.Model):
id_personaje = models.OneToOneField(Personaje, on_delete=models.CASCADE)
energia = models.IntegerField(default='100')
damage_hechizos = models.IntegerField(default='10')
def __str__(self):
return self.energia
class Hechicero(models.Model):
id_personaje = models.OneToOneField(Personaje, on_delete=models.CASCADE)
furia = models.IntegerField(default='100')
def __str__(self):
return self.furia
class Mascota(models.Model):
id_personaje = models.OneToOneField(Personaje, on_delete=models.CASCADE)
damage = models.IntegerField(default=1)
vida = models.IntegerField(default=0)
especialidad = models.CharField(max_length=20,default='')
def __str__(self):
return self.damage+"\t"+self.vida
class Almacen(models.Model):
limiteItems = models.IntegerField(default=20)
def __str__(self):
return self.limiteItems
class Item(models.Model):
id_almacen = models.ForeignKey(Almacen, on_delete=models.CASCADE)
rango = models.IntegerField(default=0)
peso = models.DecimalField(max_digits=2, decimal_places=2)
clasificacion = models.IntegerField(default=0)
costo = models.IntegerField(default=0)
def __str__(self):
return self.clasificacion
"""
class Amigos(models.Model):
id_usuario = models.ForeignKey(Usuario, on_delete=models.CASCADE)
id_amigo = models.ForeignKey(Usuario, on_delete=models.CASCADE)
Nickname_amigo = models.CharField(max_length=100,default='')
def __str__(self):
return self.Nickname_amigo
"""
| 37.041096 | 78 | 0.732618 | 333 | 2,704 | 5.741742 | 0.24024 | 0.131799 | 0.183054 | 0.066946 | 0.452929 | 0.411088 | 0.315377 | 0.292364 | 0.226464 | 0.178347 | 0 | 0.020114 | 0.154216 | 2,704 | 72 | 79 | 37.555556 | 0.815916 | 0.008876 | 0 | 0.192308 | 0 | 0 | 0.00924 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.134615 | false | 0.019231 | 0.057692 | 0.134615 | 1 | 0 | 0 | 0 | 0 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
dd55b6450d2279c2fdee3e3323752a703b0263f6 | 279 | py | Python | src/mmw/apps/modeling/admin.py | lsetiawan/model-my-watershed | 4646ebb486cb7902dce1b13c9ada32e80d22fcf0 | [
"Apache-2.0"
] | 45 | 2015-05-25T22:55:21.000Z | 2022-02-27T14:51:52.000Z | src/mmw/apps/modeling/admin.py | lsetiawan/model-my-watershed | 4646ebb486cb7902dce1b13c9ada32e80d22fcf0 | [
"Apache-2.0"
] | 3,213 | 2015-05-22T00:32:00.000Z | 2022-03-31T15:05:08.000Z | src/mmw/apps/modeling/admin.py | lsetiawan/model-my-watershed | 4646ebb486cb7902dce1b13c9ada32e80d22fcf0 | [
"Apache-2.0"
] | 37 | 2015-05-22T12:30:46.000Z | 2021-09-10T02:13:44.000Z | # -*- coding: utf-8 -*-
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import division
from django.contrib import admin
from apps.modeling.models import Project, Scenario
admin.site.register(Project)
admin.site.register(Scenario)
| 25.363636 | 50 | 0.817204 | 37 | 279 | 5.783784 | 0.567568 | 0.140187 | 0.224299 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.004016 | 0.107527 | 279 | 10 | 51 | 27.9 | 0.855422 | 0.075269 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | true | 0 | 0.714286 | 0 | 0.714286 | 0.142857 | 0 | 0 | 0 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
dd5e76422f6f7b08e04e139e3bd9aac6efcc1628 | 1,428 | py | Python | python/src/main/python/pygw/base/range.py | radiant-maxar/geowave | 2d9f39d32e4621c8f5965a4dffff0623c1c03231 | [
"Apache-2.0"
] | 280 | 2017-06-14T01:26:19.000Z | 2022-03-28T15:45:23.000Z | python/src/main/python/pygw/base/range.py | radiant-maxar/geowave | 2d9f39d32e4621c8f5965a4dffff0623c1c03231 | [
"Apache-2.0"
] | 458 | 2017-06-12T20:00:59.000Z | 2022-03-31T04:41:59.000Z | python/src/main/python/pygw/base/range.py | radiant-maxar/geowave | 2d9f39d32e4621c8f5965a4dffff0623c1c03231 | [
"Apache-2.0"
] | 135 | 2017-06-12T20:39:34.000Z | 2022-03-15T13:42:30.000Z | #
# Copyright (c) 2013-2020 Contributors to the Eclipse Foundation
#
# See the NOTICE file distributed with this work for additional information regarding copyright
# ownership. All rights reserved. This program and the accompanying materials are made available
# under the terms of the Apache License, Version 2.0 which accompanies this distribution and is
# available at http://www.apache.org/licenses/LICENSE-2.0.txt
# ===============================================================================================
from .geowave_object import GeoWaveObject
from .java_transformer import JavaTransformer
from ..config import java_pkg
class Range(GeoWaveObject):
def __init__(self, minimum=0, maximum=0, java_ref=None):
if java_ref is None:
java_ref = java_pkg.org.apache.commons.lang3.Range.between(float(minimum), float(maximum))
super().__init__(java_ref)
def get_minimum(self):
return self._java_ref.getMinimum()
def get_maximum(self):
return self._java_ref.getMaximum()
class RangeTransformer(JavaTransformer):
"""
Transforms Java Ranges into a pygw Range.
"""
def transform(self, j_object):
"""
Transform the given Java Range into a tuple.
Args:
j_object (Java Range): A Range Java object.
Returns:
A pygw implementation of Range.
"""
return Range(java_ref=j_object)
| 32.454545 | 102 | 0.655462 | 175 | 1,428 | 5.2 | 0.52 | 0.053846 | 0.030769 | 0.03956 | 0.046154 | 0 | 0 | 0 | 0 | 0 | 0 | 0.013193 | 0.203782 | 1,428 | 43 | 103 | 33.209302 | 0.787159 | 0.482493 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.266667 | false | 0 | 0.2 | 0.133333 | 0.8 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
dd6ec625100836c1f63f5bb360401ef1403bd0b9 | 334 | py | Python | pycorrector/ccm_conf.py | ccm120/pycorrector | ba44731c7fdbdc2a5d367adc3f41c51d70b25ad9 | [
"Apache-2.0"
] | null | null | null | pycorrector/ccm_conf.py | ccm120/pycorrector | ba44731c7fdbdc2a5d367adc3f41c51d70b25ad9 | [
"Apache-2.0"
] | null | null | null | pycorrector/ccm_conf.py | ccm120/pycorrector | ba44731c7fdbdc2a5d367adc3f41c51d70b25ad9 | [
"Apache-2.0"
] | null | null | null | import os
pwd_path = os.path.abspath(os.path.dirname(__file__))
# 领导人排序
name_sort_path = os.path.join(pwd_path, 'data/LSQLIB.txt')
leader_job_path = os.path.join(pwd_path, 'data/LNDLIB.txt')
quotation_word_path = os.path.join(pwd_path, 'data/QTLIB.txt')
leader_job_freq_dict_path = os.path.join(pwd_path, 'data/leader_job_freq.txt')
| 37.111111 | 78 | 0.778443 | 60 | 334 | 3.983333 | 0.366667 | 0.150628 | 0.209205 | 0.23431 | 0.41841 | 0.41841 | 0.41841 | 0 | 0 | 0 | 0 | 0 | 0.071856 | 334 | 8 | 79 | 41.75 | 0.770968 | 0.01497 | 0 | 0 | 0 | 0 | 0.207951 | 0.073395 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.166667 | 0 | 0.166667 | 0 | 0 | 0 | 0 | null | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
dd85080a0bc8d6a48b7d2f5ab49e00fd0d1ac003 | 357 | py | Python | appdigiconsult/models.py | leandrocaprara/DigiConsult | 3a57c56203584414910711fce1639b8e90292de8 | [
"MIT"
] | 1 | 2020-04-23T21:38:57.000Z | 2020-04-23T21:38:57.000Z | appdigiconsult/models.py | leandrocaprara/digiconsult | 3a57c56203584414910711fce1639b8e90292de8 | [
"MIT"
] | null | null | null | appdigiconsult/models.py | leandrocaprara/digiconsult | 3a57c56203584414910711fce1639b8e90292de8 | [
"MIT"
] | null | null | null | from django.db import models
# Create your models here.
class Pacientes(models.Model):
nome = models.CharField(max_length=50, blank=False, null=True, verbose_name=u'Nome')
cpf = models.CharField(max_length=11, blank=False, null=True, verbose_name=u'CPF')
class Meta:
ordering = ['-pk']
def __str__(self):
return self.nome | 27.461538 | 88 | 0.689076 | 51 | 357 | 4.666667 | 0.627451 | 0.12605 | 0.151261 | 0.201681 | 0.252101 | 0.252101 | 0.252101 | 0 | 0 | 0 | 0 | 0.013793 | 0.187675 | 357 | 13 | 89 | 27.461538 | 0.806897 | 0.067227 | 0 | 0 | 0 | 0 | 0.03012 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.125 | false | 0 | 0.125 | 0.125 | 0.875 | 0 | 0 | 0 | 0 | null | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 3 |
06c33ba56d1335eaa0535e91062f8dd090c895b1 | 928 | py | Python | pipeline/output_pipeline.py | Forestjylee/scut_spider | 8b37f4d714da0dd93451f22cabbc05acfd40b129 | [
"MIT"
] | 1 | 2019-04-20T03:39:14.000Z | 2019-04-20T03:39:14.000Z | pipeline/output_pipeline.py | Forest75/scut_spider | 8b37f4d714da0dd93451f22cabbc05acfd40b129 | [
"MIT"
] | 2 | 2021-03-31T19:12:04.000Z | 2021-12-13T20:02:09.000Z | pipeline/output_pipeline.py | Forest75/scut_spider | 8b37f4d714da0dd93451f22cabbc05acfd40b129 | [
"MIT"
] | null | null | null | # -*- coding: utf-8 -*-
"""
爬取信息输出管道
@file: output_pipeline.py
@time: 2019/4/18 15:50
Created by Junyi
"""
from pprint import pprint
from pipeline.mongo_pipeline import MongoPipeline
class OutputPipeline(object):
"""
输出管道实现类
注意:
由于可能用于多进程环境下执行,
若需要保存到文件中则需使用文件锁保证同步,
推荐保存在数据库中
"""
def __init__(self, config_parser):
"""
:param config_parser: 配置解析器
"""
self.op = MongoPipeline(config_parser) \
if config_parser.getboolean("mongoDB", "switch") else PrintPipeline()
def save(self, data: dict):
"""
将信息保存到指定位置
:param data: 数据信息
:return:
"""
self.op.save_data(data)
class PrintPipeline(object):
def __init__(self):
pass
@staticmethod
def save_data(data: dict) -> None:
"""
将信息输出到控制台
:param data: 信息
:return: None
"""
pprint(data)
| 18.938776 | 81 | 0.577586 | 94 | 928 | 5.531915 | 0.585106 | 0.092308 | 0.042308 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.018663 | 0.307112 | 928 | 48 | 82 | 19.333333 | 0.790047 | 0.283405 | 0 | 0 | 0 | 0 | 0.024762 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.285714 | false | 0.071429 | 0.142857 | 0 | 0.571429 | 0.142857 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 3 |
06ce9278cc07bbef718f5e3ea868339fc1df5a03 | 1,297 | py | Python | tasks/patched-python/goldreich.py | HackerDom/qctf-starter-2018 | f4eef0fd41d777661b9fbcc61dcee9709d9f6268 | [
"MIT"
] | 8 | 2018-03-15T12:07:11.000Z | 2020-12-01T15:02:46.000Z | tasks/patched-python/goldreich.py | HackerDom/qctf-starter-2018 | f4eef0fd41d777661b9fbcc61dcee9709d9f6268 | [
"MIT"
] | 17 | 2020-01-28T22:17:42.000Z | 2022-03-11T23:18:09.000Z | tasks/patched-python/goldreich.py | HackerDom/qctf-starter-2018 | f4eef0fd41d777661b9fbcc61dcee9709d9f6268 | [
"MIT"
] | 2 | 2018-11-26T18:54:27.000Z | 2018-12-05T17:37:32.000Z | import itertools
import random
N = 128
D = 10
SEED = 'substitutethis'
def generate_subsets(n, d):
S = []
indices = range(n)
for _ in range(n):
S.append(sorted(random.sample(indices, d)))
return S
def construct_predicate(true_arguments):
def predicate(bit_string):
return '1' if bit_string in true_arguments else '0'
return predicate
def generate_predicate(d):
true_arguments = set()
for bit_string in itertools.product('01', repeat=d):
if random.random() < 0.5:
true_arguments.add(''.join(bit_string))
return construct_predicate(true_arguments)
def construct_owf(subsets, predicate):
def owf(bit_string):
return ''.join(
predicate(''.join(
bit_string[index]
for index in subset))
for subset in subsets)
return owf
def generate_owf(n, d):
return construct_owf(generate_subsets(n, d), generate_predicate(d))
def generate_input(n):
return ''.join(random.choice('01') for _ in range(n))
def format_output(bit_string):
return hex(int(bit_string, 2))[2:]
def main(seed):
random.seed(seed)
return 'QCTF{{{}}}'.format(format_output(generate_owf(N, D)(generate_input(N))))
if __name__ == '__main__':
print(main(SEED))
| 21.262295 | 84 | 0.645335 | 175 | 1,297 | 4.571429 | 0.297143 | 0.09 | 0.075 | 0.0425 | 0.085 | 0 | 0 | 0 | 0 | 0 | 0 | 0.01503 | 0.230532 | 1,297 | 60 | 85 | 21.616667 | 0.786573 | 0 | 0 | 0 | 1 | 0 | 0.029298 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0.25 | false | 0 | 0.05 | 0.125 | 0.55 | 0.025 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 3 |
06d3c9f400026590f5e0754966f027e1bd11995d | 88 | py | Python | unitext/parsers/__init__.py | evfredericksen/unitext | 36569c05a2406325169f1faa834128aa98e609ce | [
"MIT"
] | null | null | null | unitext/parsers/__init__.py | evfredericksen/unitext | 36569c05a2406325169f1faa834128aa98e609ce | [
"MIT"
] | null | null | null | unitext/parsers/__init__.py | evfredericksen/unitext | 36569c05a2406325169f1faa834128aa98e609ce | [
"MIT"
] | null | null | null | from unitext.parsers.plaintext.obj import PlainTextParser
__all__ = ['PlainTextParser'] | 29.333333 | 57 | 0.829545 | 9 | 88 | 7.666667 | 0.888889 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.079545 | 88 | 3 | 58 | 29.333333 | 0.851852 | 0 | 0 | 0 | 0 | 0 | 0.168539 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.5 | 0 | 0.5 | 0 | 1 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
66068daf75504bafd2c282ec0a888218cc5197b3 | 559 | py | Python | data/train/python/66068daf75504bafd2c282ec0a888218cc5197b3DTMLDocument.py | harshp8l/deep-learning-lang-detection | 2a54293181c1c2b1a2b840ddee4d4d80177efb33 | [
"MIT"
] | 84 | 2017-10-25T15:49:21.000Z | 2021-11-28T21:25:54.000Z | data/train/python/66068daf75504bafd2c282ec0a888218cc5197b3DTMLDocument.py | vassalos/deep-learning-lang-detection | cbb00b3e81bed3a64553f9c6aa6138b2511e544e | [
"MIT"
] | 5 | 2018-03-29T11:50:46.000Z | 2021-04-26T13:33:18.000Z | data/train/python/66068daf75504bafd2c282ec0a888218cc5197b3DTMLDocument.py | vassalos/deep-learning-lang-detection | cbb00b3e81bed3a64553f9c6aa6138b2511e544e | [
"MIT"
] | 24 | 2017-11-22T08:31:00.000Z | 2022-03-27T01:22:31.000Z | from App.special_dtml import DTMLFile
from OFS.DTMLDocument import DTMLDocument
from Products.ERP5Type import _dtmldir
# Patch for displaying textearea in full window instead of
# remembering a quantity of lines to display in a cookie
manage_editForm = DTMLFile("documentEdit", _dtmldir)
manage_editForm._setName('manage_editForm')
DTMLDocument.manage_editForm = manage_editForm
DTMLDocument.manage = manage_editForm
DTMLDocument.manage_main = manage_editForm
DTMLDocument.manage_editDocument = manage_editForm
DTMLDocument.manage_editForm = manage_editForm
| 39.928571 | 58 | 0.856887 | 69 | 559 | 6.710145 | 0.478261 | 0.302376 | 0.280778 | 0.345572 | 0.233261 | 0.233261 | 0.233261 | 0 | 0 | 0 | 0 | 0.00198 | 0.096601 | 559 | 13 | 59 | 43 | 0.914851 | 0.198569 | 0 | 0.2 | 0 | 0 | 0.060674 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.3 | 0 | 0.3 | 0 | 0 | 0 | 0 | null | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
661afce764cb7537e7297dd08a1953fdb0618077 | 254 | py | Python | Imagens/admin.py | luigiMinardi/dive_code_alura | c7163e20a565d6aef3cb47bc67462495d9ad7c7f | [
"MIT"
] | null | null | null | Imagens/admin.py | luigiMinardi/dive_code_alura | c7163e20a565d6aef3cb47bc67462495d9ad7c7f | [
"MIT"
] | null | null | null | Imagens/admin.py | luigiMinardi/dive_code_alura | c7163e20a565d6aef3cb47bc67462495d9ad7c7f | [
"MIT"
] | null | null | null | from django.contrib import admin
from Imagens.models import Imagem
class ListandoImagens(admin.ModelAdmin):
list_display = ('id', 'descricao', 'foto', 'data')
list_display_link = ('id', 'descricao')
admin.site.register(Imagem, ListandoImagens)
| 28.222222 | 53 | 0.744094 | 30 | 254 | 6.2 | 0.666667 | 0.11828 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.125984 | 254 | 8 | 54 | 31.75 | 0.837838 | 0 | 0 | 0 | 0 | 0 | 0.11811 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.333333 | 0 | 0.833333 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 3 |
66407a6e799f64c6a2b7f44b945e9f5275cce49a | 227 | py | Python | reviews/get_page.py | YakhyaevRasul/the-voice.uz | 9abe0030c2fca39b5b11641ccf97ff8469785fe6 | [
"MIT"
] | null | null | null | reviews/get_page.py | YakhyaevRasul/the-voice.uz | 9abe0030c2fca39b5b11641ccf97ff8469785fe6 | [
"MIT"
] | null | null | null | reviews/get_page.py | YakhyaevRasul/the-voice.uz | 9abe0030c2fca39b5b11641ccf97ff8469785fe6 | [
"MIT"
] | null | null | null | import requests
from fb_page_access_token import page_access_token
rating = requests.get('https://graph.facebook.com/v12.0/{page-id}/ratings/',
headers = {'Authorization': f"Bearer {page_access_token}"}) | 45.4 | 81 | 0.704846 | 30 | 227 | 5.1 | 0.7 | 0.196078 | 0.294118 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.015789 | 0.162996 | 227 | 5 | 81 | 45.4 | 0.789474 | 0 | 0 | 0 | 0 | 0 | 0.394737 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | false | 0 | 0.5 | 0 | 0.5 | 0 | 0 | 0 | 0 | null | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | null | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.