ed-api-client 0.1.4__tar.gz → 0.1.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ed-api-client
3
- Version: 0.1.4
3
+ Version: 0.1.6
4
4
  Summary: A client for interacting with the Ed LMS
5
5
  License: MIT
6
6
  Author: David Milne
@@ -8,29 +8,29 @@ import re
8
8
 
9
9
  from ed_api_client.websockets import File
10
10
 
11
- class StringSet:
11
+ class Selections(List[str]):
12
12
  def __init__(self):
13
- self.strings = set()
13
+ super().__init__()
14
14
 
15
15
  def add(self, s: str):
16
16
 
17
- if self.is_subsumed(s):
17
+ stripped_s = s.strip()
18
+
19
+ if self.is_subsumed(stripped_s):
18
20
  return
19
21
 
20
- for candidate in list(self.strings):
21
- if candidate in s.strip():
22
- self.strings.remove(candidate)
23
-
24
- self.strings.add(s.strip())
22
+ for candidate in list(self):
23
+ if candidate in stripped_s:
24
+ self.remove(candidate)
25
+
26
+ self.add(stripped_s)
25
27
 
26
28
  def contains(self, s: str) -> bool:
27
- return s.strip() in self.strings
28
-
29
- def is_subsumed(self, s: str) -> bool:
30
29
  stripped_s = s.strip()
31
30
  for candidate in self.strings:
32
- if candidate in stripped_s:
31
+ if stripped_s in candidate :
33
32
  return True
33
+
34
34
  return False
35
35
 
36
36
 
@@ -449,7 +449,7 @@ class FileSummary(File):
449
449
  typing_time: datetime.timedelta = datetime.timedelta(0)
450
450
  prev_typing_time: datetime.datetime = None
451
451
 
452
- selections: List[str] = field(default_factory=list)
452
+ selections: Selections = field(default_factory=list)
453
453
  external_pastes: List[str] = field(default_factory=list)
454
454
 
455
455
  pasted_proportion: float = 0
@@ -516,8 +516,7 @@ class WorkspaceSummary:
516
516
  total_typing_time: datetime.timedelta
517
517
 
518
518
  file_summaries: Dict[int, FileSummary]
519
- selections: List[Selection] = field(default_factory=list)
520
-
519
+
521
520
  def from_log(
522
521
  files: List[File],
523
522
  log: WorkspaceLog,
@@ -565,7 +564,7 @@ class WorkspaceSummary:
565
564
  for file in files:
566
565
  file_summaries[file.id] = FileSummary.from_file(file)
567
566
 
568
- selected_content = StringSet()
567
+ selected_content = Selections()
569
568
 
570
569
  for selection in acceptable_selections:
571
570
  selected_content.add(selection)
@@ -587,7 +586,7 @@ class WorkspaceSummary:
587
586
  selected_content.add(sel_text.strip())
588
587
  sel_file = file_summaries.get(sel_file_id)
589
588
  if sel_file is not None:
590
- sel_file.selections.append(sel_text.strip())
589
+ sel_file.selections.add(sel_text.strip())
591
590
  if '\n' in sel_text:
592
591
  sel_file.multiline_selection_count += 1
593
592
 
@@ -691,7 +690,7 @@ class WorkspaceSummary:
691
690
  )
692
691
 
693
692
  if len(edit.value) > min_suspicious_paste_chars:
694
- if not selected_content.is_subsumed(edit.value):
693
+ if not selected_content.contains(edit.value):
695
694
  file.external_pastes.append(edit.value)
696
695
 
697
696
  file._insert_positions.append(pos / max(len(file.content), 1))
@@ -714,10 +713,10 @@ class WorkspaceSummary:
714
713
  if pending_selection is not None:
715
714
  sel_text, sel_file_id = pending_selection[2], pending_selection[3]
716
715
  selected_content.add(sel_text.strip())
717
- selections.append(Selection(*pending_selection))
718
- if '\n' in sel_text:
719
- sel_file = file_summaries.get(sel_file_id)
720
- if sel_file is not None:
716
+ sel_file = file_summaries.get(sel_file_id)
717
+ if sel_file is not None:
718
+ sel_file.selections.append(sel_text.strip())
719
+ if '\n' in sel_text:
721
720
  sel_file.multiline_selection_count += 1
722
721
 
723
722
  total_active_time = datetime.timedelta(0)
@@ -750,4 +749,4 @@ class WorkspaceSummary:
750
749
  if file._pending_deletion and '\n' in file._pending_deletion:
751
750
  file.multiline_deletion_count += 1
752
751
 
753
- return WorkspaceSummary(total_active_time, total_typing_time, file_summaries, selections)
752
+ return WorkspaceSummary(total_active_time, total_typing_time, file_summaries)
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "ed-api-client"
3
- version = "0.1.4"
3
+ version = "0.1.6"
4
4
  description = "A client for interacting with the Ed LMS"
5
5
  authors = ["David Milne <d.n.milne@gmail.com>"]
6
6
  license = "MIT"
File without changes