function
stringlengths
11
56k
repo_name
stringlengths
5
60
features
list
def is_good_for_setup(self): """checks if the objects rotatePivot, scalePivot, rotatePivotTranslate and scalePivotTranslate is not connected to anything """ attributes = [ "rotatePivot", "scalePivot", "rotatePivotTranslate", "scalePivotTran...
eoyilmaz/anima
[ 119, 27, 119, 3, 1392807749 ]
def setup_pivot(): """setups pivot switching for selected objects""" for piv_switcher in get_one_switcher(): piv_switcher.setup()
eoyilmaz/anima
[ 119, 27, 119, 3, 1392807749 ]
def test (*args, *kwargs): print args, kwargs
theodox/mGui
[ 117, 23, 117, 15, 1392580211 ]
def test (*args, *kwargs): print "args:", args print "kwargs:", kwargs
theodox/mGui
[ 117, 23, 117, 15, 1392580211 ]
def __init__(self, **data): self._handlers = set() '''Set list of handlers callables. Use a set to avoid multiple calls on one handler''' self.data = data self.data['event'] = self
theodox/mGui
[ 117, 23, 117, 15, 1392580211 ]
def _remove_handler(self, handler): """ Remove a handler. Ignores handlers that are not present. """ stash = None if isinstance(handler, tuple): handler, stash = handler try: delattr(stash, '_sh_{}'.format(id(handler))) except AttributeErr...
theodox/mGui
[ 117, 23, 117, 15, 1392580211 ]
def _fire(self, *args, **kwargs): """ Call all handlers. Any decayed references will be purged. """ delenda = [] for handler in self._handlers: try: handler(*args, **self.metadata(kwargs)) except DeadReferenceError: delend...
theodox/mGui
[ 117, 23, 117, 15, 1392580211 ]
def __del__(self): print 'event expired'
theodox/mGui
[ 117, 23, 117, 15, 1392580211 ]
def _fire(self, *args, **kwargs): """ Call all handlers. Any decayed references will be purged. """ delenda = [] for handler in self._handlers: try: maya.utils.executeDeferred(partial(handler, *args, **self.metadata(kwargs))) except DeadR...
theodox/mGui
[ 117, 23, 117, 15, 1392580211 ]
def __init__(self, f): self.function = f.im_func self.referent = weakref.ref(f.im_self) self._ref_name = f.im_func.__name__ self.ID = id(f.im_self) ^ id(f.im_func.__name__)
theodox/mGui
[ 117, 23, 117, 15, 1392580211 ]
def __eq__(self, other): if not hasattr(other, 'ID'): return False return self.ID == other.ID
theodox/mGui
[ 117, 23, 117, 15, 1392580211 ]
def __init__(self, f): self.function = weakref.ref(f) self.ID = id(f) self._ref_name = getattr(f, '__name__', "'unnamed'")
theodox/mGui
[ 117, 23, 117, 15, 1392580211 ]
def __eq__(self, other): if not hasattr(other, 'ID'): return False return self.ID == other.ID
theodox/mGui
[ 117, 23, 117, 15, 1392580211 ]
def get_weak_reference(f): """ Returns a WeakMethodFree or a WeakMethodBound for the supplied function, as appropriate """ try: f.im_func except AttributeError: return WeakMethodFree(f) return WeakMethodBound(f)
theodox/mGui
[ 117, 23, 117, 15, 1392580211 ]
def wrapper(*_, **__): return fn()
theodox/mGui
[ 117, 23, 117, 15, 1392580211 ]
def help(self,letter='az',typ='mt'): """ generic help Parameters ---------- txt : string 'mb' | 'mt' mb :members mt :methods """ members = [ x for x in self.__dict__.keys() if x not in dict.__dict__ ] lmeth = [ x for x in n...
pylayers/pylayers
[ 152, 102, 152, 115, 1346426390 ]
def __init__(self): self.mapped_emails = {} self.mapped_names = {} self.generated_emails = set() self.generated_names = set()
ENCODE-DCC/encoded
[ 104, 54, 104, 70, 1354841541 ]
def replace_non_pi_names(self, dictrows): for row in dictrows: if row.get('job_title') != 'PI': if 'first_name' in row: row['first_name'] = random.choice(self.random_words).capitalize() if 'last_name' in row: row['last_name'] = ...
ENCODE-DCC/encoded
[ 104, 54, 104, 70, 1354841541 ]
def _replace_emails(self, matchobj): found = matchobj.group(0) new, original = self.mapped_emails.get(found.lower(), (None, None)) if new is not None: if found != original: raise ValueError( "Case mismatch for %s, %s" % (found, original)) ...
ENCODE-DCC/encoded
[ 104, 54, 104, 70, 1354841541 ]
def set_existing_key_value(**kw): def component(dictrows): for row in dictrows: for k, v in kw.items(): if k in row: row[k] = v yield row return component
ENCODE-DCC/encoded
[ 104, 54, 104, 70, 1354841541 ]
def component(dictrows): for row in dictrows: if not all(row[k] == v if k in row else False for k, v in kw.items()): yield row
ENCODE-DCC/encoded
[ 104, 54, 104, 70, 1354841541 ]
def extract_pipeline(): return [ skip_rows_with_all_falsey_value('test'), skip_rows_with_all_key_value(test='skip'), skip_rows_with_all_falsey_value('test'), skip_rows_missing_all_keys('uuid'), drop_rows_with_all_key_value(_skip=True), ]
ENCODE-DCC/encoded
[ 104, 54, 104, 70, 1354841541 ]
def run(pipeline, inpath, outpath): for item_type in ORDER: source = read_single_sheet(inpath, item_type) fieldnames = [k for k in source.fieldnames if ':ignore' not in k] with open(os.path.join(outpath, item_type + '.tsv'), 'wb') as out: writer = csv.DictWriter(out, fieldnames, ...
ENCODE-DCC/encoded
[ 104, 54, 104, 70, 1354841541 ]
def negate(grads): """Negates the gradients. Args: grads: A numpy array of grads to use. Returns: The negated gradients. """ return -grads
raghakot/keras-vis
[ 2947, 669, 2947, 117, 1478906854 ]
def invert(grads): """Inverts the gradients. Args: grads: A numpy array of grads to use. Returns: The inverted gradients. """ return 1. / (grads + K.epsilon())
raghakot/keras-vis
[ 2947, 669, 2947, 117, 1478906854 ]
def small_values(grads): """Can be used to highlight small gradient values. Args: grads: A numpy array of grads to use. Returns: The modified gradients that highlight small values. """ return absolute(invert(grads))
raghakot/keras-vis
[ 2947, 669, 2947, 117, 1478906854 ]
def test_error_code(self): self.assertEqual(-1000, WeChatErrorCode.SYSTEM_ERROR.value) self.assertEqual(42001, WeChatErrorCode.EXPIRED_ACCESS_TOKEN.value) self.assertEqual(48001, WeChatErrorCode.UNAUTHORIZED_API.value)
wechatpy/wechatpy
[ 3364, 745, 3364, 44, 1410527008 ]
def get_categories(self) -> List[int]: res = [] for t in list(VehicleCategory): if self in t.value: res.append(t) return res
hasadna/anyway
[ 69, 235, 69, 293, 1386619033 ]
def to_type_code(db_val: Union[float, int]) -> int: """Values read from DB may arrive as float, and empty values come as nan""" if isinstance(db_val, float): if math.isnan(db_val): return VehicleType.OTHER_AND_UNKNOWN.value else: return int(db_val)...
hasadna/anyway
[ 69, 235, 69, 293, 1386619033 ]
def get_codes(self) -> List[int]: """returns VehicleType codes of category""" category_vehicle_types = { VehicleCategory.PROFESSIONAL_DRIVER: [ VehicleType.TRUCK_UPTO_4, VehicleType.PICKUP_UPTO_4, VehicleType.TRUCK_4_TO_10, Vehi...
hasadna/anyway
[ 69, 235, 69, 293, 1386619033 ]
def get_english_display_name(self): english_vehicle_type_display_names = { VehicleCategory.PROFESSIONAL_DRIVER: "professional driver", VehicleCategory.PRIVATE_DRIVER: "private driver", VehicleCategory.LIGHT_ELECTRIC: "light electric vehicles", VehicleCategory.CAR:...
hasadna/anyway
[ 69, 235, 69, 293, 1386619033 ]
def read_image_from_stream(stream): try: arr = np.asarray(bytearray(stream.read()), dtype=np.uint8) image = cv2.imdecode(arr, cv2.IMREAD_COLOR) height, width = image.shape[:2] if height <= 0 or width <= 0: raise Exception('Invalid image file from stream') except: ...
meerkat-cv/annotator-supreme
[ 5, 1, 5, 15, 1497297407 ]
def read_image_b64(base64_string): dec = base64.b64decode(base64_string) npimg = np.fromstring(dec, dtype=np.uint8) cvimg = cv2.imdecode(npimg, cv2.IMREAD_COLOR) return cvimg
meerkat-cv/annotator-supreme
[ 5, 1, 5, 15, 1497297407 ]
def parse_content_type(request): """ This function is used to extract the content type from the header. """ try: content_type = request.headers['content-type'] except: raise error_views.InvalidParametersError('No Content-Type provided') json_type = 'application/json' data_ty...
meerkat-cv/annotator-supreme
[ 5, 1, 5, 15, 1497297407 ]
def create_db(self): try: return MongoDB(database='iptestdb', _connection=c) except Exception: raise SkipTest("Couldn't connect to mongodb")
mattvonrocketstein/smash
[ 12, 1, 12, 10, 1321798817 ]
def __init__( self, plotly_name="color", parent_name="heatmapgl.hoverlabel.font", **kwargs
plotly/plotly.py
[ 13052, 2308, 13052, 1319, 1385013188 ]
def runtests(): # set verbosity to 2 to see each test unittest.TextTestRunner(verbosity=1, buffer=True).run(suite)
wanqizhu/mtg-python-engine
[ 29, 14, 29, 1, 1501541949 ]
def parse_args():
kahst/BirdCLEF2017
[ 38, 13, 38, 4, 1494853753 ]
def changeSampleRate(sig, rate): duration = sig.shape[0] / rate time_old = np.linspace(0, duration, sig.shape[0]) time_new = np.linspace(0, duration, int(sig.shape[0] * 44100 / rate)) interpolator = interpolate.interp1d(time_old, sig.T) new_audio = interpolator(time_new).T sig = np.round(n...
kahst/BirdCLEF2017
[ 38, 13, 38, 4, 1494853753 ]
def getMagSpec(sig, rate, winlen, winstep, NFFT): #get frames winfunc = lambda x:np.ones((x,)) frames = psf.sigproc.framesig(sig, winlen*rate, winstep*rate, winfunc)
kahst/BirdCLEF2017
[ 38, 13, 38, 4, 1494853753 ]
def getMultiSpec(path, seconds=5, overlap=2, minlen=1, winlen=0.05, winstep=0.0097, NFFT=840): #open wav file (rate,sig) = wave.read(path) #adjust to different sample rates if rate != 44100: sig, rate = changeSampleRate(sig, rate) #split signal with overlap sig_splits = [] for i i...
kahst/BirdCLEF2017
[ 38, 13, 38, 4, 1494853753 ]
def buildModel(mtype=1): print "BUILDING MODEL TYPE", mtype, "..." #default settings (Model 1) filters = 64 first_stride = 2 last_filter_multiplier = 16 #specific model type settings (see working notes for details) if mtype == 2: first_stride = 1 elif mtype == 3: filte...
kahst/BirdCLEF2017
[ 38, 13, 38, 4, 1494853753 ]
def loadParams(epoch, filename=None): print "IMPORTING MODEL PARAMS...", net_filename = MODEL_PATH + filename with open(net_filename, 'rb') as f: params = pickle.load(f) l.set_all_param_values(NET, params) print "DONE!"
kahst/BirdCLEF2017
[ 38, 13, 38, 4, 1494853753 ]
def getPredictionFuntion(net): net_output = l.get_output(net, deterministic=True) print "COMPILING THEANO TEST FUNCTION...", start = time.time() test_net = theano.function([l.get_all_layers(NET)[0].input_var], net_output, allow_input_downcast=True) print "DONE! (", int(time.time() - start), "s )" ...
kahst/BirdCLEF2017
[ 38, 13, 38, 4, 1494853753 ]
def predictionPooling(p): #You can test different prediction pooling strategies here #We only use average pooling p_pool = np.mean(p, axis=0) return p_pool
kahst/BirdCLEF2017
[ 38, 13, 38, 4, 1494853753 ]
def predict(img): #transpose image if dim=3 try: img = np.transpose(img, (2, 0, 1)) except: pass #reshape image img = img.reshape(-1, IM_DIM, IM_SIZE[1], IM_SIZE[0]) #calling the test function returns the net output prediction = TEST_NET(img)[0] return prediction
kahst/BirdCLEF2017
[ 38, 13, 38, 4, 1494853753 ]
def testFile(path, spec_overlap=4, num_results=5, confidence_threshold=0.01): #time start = time.time()
kahst/BirdCLEF2017
[ 38, 13, 38, 4, 1494853753 ]
def __init__(self, enum, **kwargs): self.enum = enum choices = ( (self.get_choice_value(enum_value), enum_value.label) for _, enum_value in enum.choices() ) super(EnumField, self).__init__(choices, **kwargs)
5monkeys/django-enumfield
[ 195, 46, 195, 8, 1359628484 ]
def to_internal_value(self, data): if isinstance(data, six.string_types) and data.isdigit(): data = int(data) try: value = self.enum.get(data).value except AttributeError: # .get() returned None if not self.required: raise serializers.SkipFie...
5monkeys/django-enumfield
[ 195, 46, 195, 8, 1359628484 ]
def get_choice_value(self, enum_value): return enum_value.name
5monkeys/django-enumfield
[ 195, 46, 195, 8, 1359628484 ]
def __init__( self, plotly_name="tickformat", parent_name="scattercarpet.marker.colorbar", **kwargs
plotly/python-api
[ 13052, 2308, 13052, 1319, 1385013188 ]
def compute_fourier(phases,nh=10,pow_phase=False): '''Compute Fourier amplitudes from an array of pulse phases phases should be [0,1.0) nh is the number of harmonics (1 = fundamental only) Returns: cos and sin component arrays, unless pow_phase is True then returns Fourier power (Leahy normalized) a...
paulray/NICERsoft
[ 15, 17, 15, 8, 1491322025 ]
def evaluate_chi2(hist,model): # Question here is whether error should be sqrt(data) or sqrt(model) return ((hist-model)**2/model).sum()
paulray/NICERsoft
[ 15, 17, 15, 8, 1491322025 ]
def get_num_filters(layer): """Determines the number of filters within the given `layer`. Args: layer: The keras layer to use. Returns: Total number of filters within `layer`. For `keras.layers.Dense` layer, this is the total number of outputs. """ # Handle layers with no c...
raghakot/keras-vis
[ 2947, 669, 2947, 117, 1478906854 ]
def __init__(self): self.header_fields = [] self._header_index = {} self.entries = {}
kmichel/po-localization
[ 5, 1, 5, 1, 1410389851 ]
def add_header_field(self, field, value): if field in self._header_index: self.header_fields[self._header_index[field]] = (field, value) else: self._header_index[field] = len(self.header_fields) self.header_fields.append((field, value))
kmichel/po-localization
[ 5, 1, 5, 1, 1410389851 ]
def dump(self, fp, include_locations=True, prune_obsoletes=False): needs_blank_line = False if len(self.header_fields): print('msgid ""', file=fp) print('msgstr ""', file=fp) for field, value in self.header_fields: print(r'"{}: {}\n"'.format(field, val...
kmichel/po-localization
[ 5, 1, 5, 1, 1410389851 ]
def get_catalog(self): catalog = {} for entry in self.entries.values(): entry.fill_catalog(catalog) return catalog
kmichel/po-localization
[ 5, 1, 5, 1, 1410389851 ]
def __init__(self, message, plural=None, context=None): self.message = message self.plural = plural self.context = context self.locations = [] self.translations = {}
kmichel/po-localization
[ 5, 1, 5, 1, 1410389851 ]
def add_location(self, filename, lineno): self.locations.append((filename, lineno))
kmichel/po-localization
[ 5, 1, 5, 1, 1410389851 ]
def add_plural_translation(self, index, translation): self.translations[index] = translation
kmichel/po-localization
[ 5, 1, 5, 1, 1410389851 ]
def dump(self, fp, nplurals=None, include_locations=True, prune_obsolete=False): """ If plural, shows exactly 'nplurals' plurals if 'nplurals' is not None, else shows at least min_nplurals. All plural index are ordered and consecutive, missing entries are displayed with an empty string. ...
kmichel/po-localization
[ 5, 1, 5, 1, 1410389851 ]
def multiline_escape(string): if EMBEDDED_NEWLINE_MATCHER.search(string): lines = string.split('\n') return ( '""\n' + '\n'.join('"{}\\n"'.format(escape(line)) for line in lines[:-1]) + ('\n"{}"'.format(escape(lines[-1])) if len(lines[-1]) else "")) else: ...
kmichel/po-localization
[ 5, 1, 5, 1, 1410389851 ]
def __init__( self, plotly_name="ticklen", parent_name="treemap.marker.colorbar", **kwargs
plotly/python-api
[ 13052, 2308, 13052, 1319, 1385013188 ]
def __init__(self, infile, outfile): threading.Thread.__init__(self) self.infile = infile self.outfile = outfile
CajetanP/code-learning
[ 1, 2, 1, 31, 1488493028 ]
def __init__(self,value): self.value = value
CajetanP/code-learning
[ 1, 2, 1, 31, 1488493028 ]
def __init__( self, plotly_name="tickvals", parent_name="parcoords.dimension", **kwargs
plotly/python-api
[ 13052, 2308, 13052, 1319, 1385013188 ]
def __init__(self, log_file_name=None, log_level=logging.INFO): full_log_path_and_name = KhanLogger.default_log_path_with_unique_name(log_file_name) self.logger = KhanLogger(file_path_and_name=full_log_path_and_name, level=log_level)
thorwhalen/ut
[ 4, 3, 4, 24, 1426246351 ]
def __init__(self, name): super(VFModule, self).__init__(name) self.vf = torch._C._VariableFunctions
ryfeus/lambda-packs
[ 1086, 234, 1086, 13, 1476901359 ]
def dynamics(x, u, dt): """ Returns next state given last state x, wrench u, and timestep dt. """ # Rotation matrix (orientation, converts body to world) R = np.array([ [np.cos(x[2]), -np.sin(x[2]), 0], [np.sin(x[2]), np.cos(x[2]), 0], [ ...
jnez71/lqRRT
[ 76, 27, 76, 3, 1474718253 ]
def lqr(x, u): """ Returns cost-to-go matrix S and policy matrix K given local state x and effort u. """ R = np.array([ [np.cos(x[2]), -np.sin(x[2]), 0], [np.sin(x[2]), np.cos(x[2]), 0], [ 0, 0, 1] ]) K = n...
jnez71/lqRRT
[ 76, 27, 76, 3, 1474718253 ]
def gen_ss(seed, goal, buff=[ss_start]*4): """ Returns a sample space given a seed state, goal state, and buffer. """ return [(min([seed[0], goal[0]]) - buff[0], max([seed[0], goal[0]]) + buff[1]), (min([seed[1], goal[1]]) - buff[2], max([seed[1], goal[1]]) + buff[3]), (-np.pi, ...
jnez71/lqRRT
[ 76, 27, 76, 3, 1474718253 ]
def get_version(): """Return the version of extras that we are building.""" version = '.'.join( str(component) for component in extras.__version__[0:3]) return version
testing-cabal/extras
[ 4, 6, 4, 3, 1351326273 ]
def __init__(self, value=0.0, *args, **kw_args): """Initialises a new 'ActivePowerLimit' instance. @param value: Value of active power limit. """ #: Value of active power limit. self.value = value super(ActivePowerLimit, self).__init__(*args, **kw_args)
rwl/PyCIM
[ 68, 33, 68, 7, 1238978196 ]
def error_404(e): """ - Displays the 404 error page. """ error_page = ((requests.get(url='http://127.0.0.1:8080/html/{}'.format('404.html'))).content).decode("utf-8") # Done return render_template_string(error_page)
sharadbhat/Video-Sharing-Platform
[ 74, 30, 74, 5, 1507245196 ]
def error_403(e): """ - Displays the 404 error page. """ error_page = ((requests.get(url='http://127.0.0.1:8080/html/{}'.format('403.html'))).content).decode("utf-8") # Done return render_template_string(error_page)
sharadbhat/Video-Sharing-Platform
[ 74, 30, 74, 5, 1507245196 ]
def start(): #WORKS """ - The starting page. - Redirects to login page if not logged in. - Redirects to dashboard if logged in. """ logged_in = False if 'user' in session: logged_in = True is_admin = (requests.get(url='http://127.0.0.1:8080/is-admin/{}'.format(session['user']...
sharadbhat/Video-Sharing-Platform
[ 74, 30, 74, 5, 1507245196 ]
def login_form(): #WORKS """ In GET request, - Redirects to dashboard if logged in. - Displays login form if not logged in. """ if request.method == 'GET': login_error = request.args.get('l_error', False) if 'user' in session: return redirect(url_for("start"))...
sharadbhat/Video-Sharing-Platform
[ 74, 30, 74, 5, 1507245196 ]
def signup_form(): #WORKS """ In GET request - Displays sign up page. """ if request.method == 'GET': if 'user' in session: return redirect(url_for('start')) signup_error = request.args.get('s_error', False) signup_page = ((requests.get(url='http://127.0.0.1:8...
sharadbhat/Video-Sharing-Platform
[ 74, 30, 74, 5, 1507245196 ]
def password_update_form(): #WORKS """ In GET request - Redirects to login page if not logged in. - Displays the password update form. """ if request.method == 'GET': u_error = request.args.get('u_error', False) if 'user' not in session: return redirect(url_fo...
sharadbhat/Video-Sharing-Platform
[ 74, 30, 74, 5, 1507245196 ]
def delete_own_account(): #WORKS """ In GET request - Displays confirmation page. """ if request.method == 'GET': if 'user' not in session: return redirect(url_for('login_form')) is_admin = (requests.get(url='http://127.0.0.1:8080/is-admin/{}'.format(session['user']))...
sharadbhat/Video-Sharing-Platform
[ 74, 30, 74, 5, 1507245196 ]
def logout_user(): #WORKS """ - Removes user from session. - Redirects to login page. """ session.pop('user', None) return redirect(url_for("start"))
sharadbhat/Video-Sharing-Platform
[ 74, 30, 74, 5, 1507245196 ]
def dashboard(): #WORKS """ - Redirects to login page if not logged in. - Displays dashboard page if logged in. """ if request.method == 'GET': if 'user' not in session: return redirect(url_for("login_form")) else: is_admin = (requests.get(url='http://127.0.0....
sharadbhat/Video-Sharing-Platform
[ 74, 30, 74, 5, 1507245196 ]
def upload_form(): #WORKS """ In GET request - Displays upload form. """ if request.method == 'GET': if 'user' not in session: return redirect(url_for('login_form')) is_admin = (requests.get(url='http://127.0.0.1:8080/is-admin/{}'.format(session['user'])).content).dec...
sharadbhat/Video-Sharing-Platform
[ 74, 30, 74, 5, 1507245196 ]
def delete_own_video(): """ In GET request - Redirects to login page if not logged in. - If the uploader and current user are the same, it deletes the video. - Redirects to dashboard. """ if request.method == 'GET': if 'user' not in session: return redirect(ur...
sharadbhat/Video-Sharing-Platform
[ 74, 30, 74, 5, 1507245196 ]
def watch_video(): #WORKS """ In GET request - Plays the video with the corresponding video ID. """ if request.method == 'GET': if 'user' in session: is_admin = (requests.get(url='http://127.0.0.1:8080/is-admin/{}'.format(session['user'])).content).decode("utf-8") # Done ...
sharadbhat/Video-Sharing-Platform
[ 74, 30, 74, 5, 1507245196 ]
def search_videos(): """ In POST request - Accepts the search key from the user. """ if request.method == 'POST': if 'user' in session: is_admin = (requests.get(url='http://127.0.0.1:8080/is-admin/{}'.format(session['user'])).content).decode("utf-8") # Done if is_...
sharadbhat/Video-Sharing-Platform
[ 74, 30, 74, 5, 1507245196 ]
def results(): """ In GET request - Displays the search results. """ if request.method == 'GET': logged_in = False if 'user' in session: logged_in = True is_admin = (requests.get(url='http://127.0.0.1:8080/is-admin/{}'.format(session['user'])).content).dec...
sharadbhat/Video-Sharing-Platform
[ 74, 30, 74, 5, 1507245196 ]
def random_video(): """ In GET request - Selects a random video from the database and redirects to the page of the video. """ if request.method == 'GET': if 'user' in session: is_admin = (requests.get(url='http://127.0.0.1:8080/is-admin/{}'.format(session['user'])).content).d...
sharadbhat/Video-Sharing-Platform
[ 74, 30, 74, 5, 1507245196 ]
def watched_videos(): """ In GET request - Displays a page of all videos watched by the user in the WATCHED tables. """ if request.method == 'GET': if 'user' not in session: return redirect(url_for('login_form')) is_admin = (requests.get(url='http://127.0.0.1:8080/is-...
sharadbhat/Video-Sharing-Platform
[ 74, 30, 74, 5, 1507245196 ]
def user_videos(username): """ In GET request - Displays a page of all videos uploaded by the user in the VIDEOS table. """ if request.method == 'GET': if 'user' in session: is_admin = (requests.get(url='http://127.0.0.1:8080/is-admin/{}'.format(session['user'])).content).dec...
sharadbhat/Video-Sharing-Platform
[ 74, 30, 74, 5, 1507245196 ]
def my_videos(): """ In GET request - Returns a page of videos uploaded by the logged in user. """ if request.method == 'GET': if 'user' not in session: return redirect(url_for('login_form')) is_admin = (requests.get(url='http://127.0.0.1:8080/is-admin/{}'.format(sess...
sharadbhat/Video-Sharing-Platform
[ 74, 30, 74, 5, 1507245196 ]
def flag_video(): """ In GET request - Flags the video. - Redirects to home page. """ if request.method == 'GET': if 'user' not in session: return redirect('login_form') is_admin = (requests.get(url='http://127.0.0.1:8080/is-admin/{}'.format(session['user']))....
sharadbhat/Video-Sharing-Platform
[ 74, 30, 74, 5, 1507245196 ]
def favourites(): """ In GET request - Displays a list of favourite videos. """ if request.method == 'GET': if 'user' in session: is_admin = (requests.get(url='http://127.0.0.1:8080/is-admin/{}'.format(session['user'])).content).decode("utf-8") # Done if is_admin...
sharadbhat/Video-Sharing-Platform
[ 74, 30, 74, 5, 1507245196 ]
def add_admin(): """ In GET request - Displays the add administrator page. """ if request.method == 'GET': if 'user' in session: is_admin = (requests.get(url='http://127.0.0.1:8080/is-admin/{}'.format(session['user'])).content).decode("utf-8") # Done if is_admin =...
sharadbhat/Video-Sharing-Platform
[ 74, 30, 74, 5, 1507245196 ]
def flagged_videos(): """ In GET request - Displays all the flagged videos. """ if request.method == 'GET': if 'user' in session: is_admin = (requests.get(url='http://127.0.0.1:8080/is-admin/{}'.format(session['user'])).content).decode("utf-8") # Done if is_admin ...
sharadbhat/Video-Sharing-Platform
[ 74, 30, 74, 5, 1507245196 ]
def admin_delete_video(): """ In GET request - Deletes the video with the corresponding video ID. """ if request.method == 'GET': if 'user' in session: is_admin = (requests.get(url='http://127.0.0.1:8080/is-admin/{}'.format(session['user'])).content).decode("utf-8") # Done ...
sharadbhat/Video-Sharing-Platform
[ 74, 30, 74, 5, 1507245196 ]
def admin_list_users(): """ In GET request - Displays a list of users. """ if request.method == 'GET': if 'user' in session: is_admin = (requests.get(url='http://127.0.0.1:8080/is-admin/{}'.format(session['user'])).content).decode("utf-8") # Done if is_admin == "T...
sharadbhat/Video-Sharing-Platform
[ 74, 30, 74, 5, 1507245196 ]
def admin_delete_user(username): """ In GET request - Deletes the user with the corresponding username. """ if request.method == 'GET': if 'user' in session: is_admin = (requests.get(url='http://127.0.0.1:8080/is-admin/{}'.format(session['user'])).content).decode("utf-8") # D...
sharadbhat/Video-Sharing-Platform
[ 74, 30, 74, 5, 1507245196 ]
def admin_review_video(): """ In GET request - The administrator can watch the video. - Delete the video. - Remove the flag. """ if request.method == 'GET': if 'user' in session: is_admin = (requests.get(url='http://127.0.0.1:8080/is-admin/{}'.format(session['...
sharadbhat/Video-Sharing-Platform
[ 74, 30, 74, 5, 1507245196 ]