Best Python code snippet using slash
Plan.py
Source:Plan.py  
...67            if not res.rstrip():68                return day_name + 'WOLNE'69            return day_name + res.rstrip()7071        def get_last_class(self):72            if not self.day_classes:73                return 074            else:75                return self.day_classes[len(self.day_classes) - 1]7677        def get_first_class(self):78            if not self.day_classes:79                return 080            else:81                return self.day_classes[0]8283    def parse_plan(self, text):84        plan_string = ''85        for i in text:86            plan_string += i87            if i == '{' or i == '[' or i == ',':88                plan_string += "\n"89        plan_array = plan_string.split('\n')9091        n = 392        m = 093        activities = []94        while not re.match(r'.*username.*', plan_array[n]):95            activity = self.PlanItem(m)96            while not re.match(r'(.*)\}', plan_array[n]):97                lin = re.search(r'"(.*)":(.*),', plan_array[n])98                if lin:99                    typ = lin.group(1)100                    val = lin.group(2)101                    val = val[1:-1]102                    if typ == 'startTime' or typ == 'endTime':103                        t = datetime.strptime(val, "%I:%M:%S %p")104                        val = datetime.strftime(t, "%H:%M")105                    setattr(activity, typ, val)106                    n += 1107                else:108                    n += 1109            n += 1110            if plan_array[n] == '{':111                n += 1112            activities.append(activity)113            m += 1114        for obj in activities:115            self.classes.append(obj)116117    def is_day_over(self):118        now = datetime.now()119        today_plan = self.Day(now.weekday() + 1, self.classes)120        if not today_plan.get_first_class():121            return True122        else:123            last_class = today_plan.get_last_class()124            last_start_hour = last_class.start_hour()125            if int(now.hour) < last_start_hour or (int(now.hour) == last_start_hour and int(now.minute) < 16):126                return False127            else:128                return True129130    def get_class_list(self):131        res = []132        b = 1133        for i in range(1, 6):134            today = self.Day(i, self.classes)135            for obj in today.classes:136                obj.set_time()137                res.append(obj)
...file.py
Source:file.py  
...42    def add_class(self):43        cls = Class(self.suite, self)44        self._classes.append(cls)45        return cls46    def get_last_class(self):47        if not self._classes:48            return None49        return self._classes[-1]50    def add_function_test(self):51        returned = NonMethodTest(self.suite, self)52        self._tests.append(returned)53        self.suite.notify_test_added(returned)54        return returned55    @contextmanager56    def _body_context(self, code_formatter):57        with super(File, self)._body_context(code_formatter):58            if self.suite.debug_info:59                code_formatter.writeln('import __ut__')60            code_formatter.writeln('import slash')...suite_strategy.py
Source:suite_strategy.py  
...12        if candidate is not None and candidate.get_num_tests() < self._max_tests_per_file:13            return candidate14        return suite.add_file()15    def get_class_for_test(self, file):16        candidate = file.get_last_class()17        if candidate is not None and candidate.get_num_tests() < self._max_tests_per_class:18            return candidate...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
