bond-spy 0.2.0 → 0.2.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c65fb7c7aa4cf11b582ae1620a91b522d88aaee3
4
- data.tar.gz: fc50ff99e60d3c387394c886d48196722f056c6c
3
+ metadata.gz: 9bdcc8391596c23a7e755612216f518376016165
4
+ data.tar.gz: b1d60856e4061fad3874d5f9e0720b1dfb72ad87
5
5
  SHA512:
6
- metadata.gz: dfaa6acd7d9c78967231e194b652db630b271d07d6091a0bc7add63b8c598bf253ca97bd9451216d98203e5a896cd51a8789b999b1ceefd2a73928b7f03aba75
7
- data.tar.gz: 72e3e53c5616f4948f8a0d0c2bbf0d758fa2df145a16161bf905421143bc49bebd1946c9596fbc4daf14a52b82f20d8edf3416e1018b6320263ea764ed1e6efe
6
+ metadata.gz: 85d8e5f478fa20a46b0ba5f06f18db65e76f292b5537546df2df9d10bc487557b5a82066b010ca6b84ce3a36b12b36db8af238066ad788914864e24b99a601af
7
+ data.tar.gz: 9e02013b8c8d1129a744708a4efb6dbba99c53a9a875fa42b9aa7c99498b3922b1461140c928d06097d48989cc66daad300c104078f695120fe584c2b52c8ad8
@@ -0,0 +1,73 @@
1
+ from Tkinter import *
2
+ from ScrolledText import ScrolledText
3
+ import functools
4
+
5
+
6
+ class OptionDialog(Frame):
7
+ """
8
+ A Tkinter dialog window used for presenting the user with custom options.
9
+ """
10
+
11
+ def __init__(self, master, prompt, options):
12
+ Frame.__init__(self, master)
13
+ self.pack()
14
+ self.last_button = options[-1]
15
+ self._create_widgets(prompt, options)
16
+ self._center(master)
17
+ master.deiconify()
18
+ # PyCharm likes to grab focus back from the dialog if the window is only marked as
19
+ # topmost temporarily, which is very annoying, so leave it as topmost.
20
+ # TODO ETK When settings are better laid out, this should be configurable.
21
+ master.attributes('-topmost', 1)
22
+
23
+ @staticmethod
24
+ def create_dialog_get_value(prompt, options):
25
+ """
26
+ The main entrypoint; creates a dialog, presents it to the user, and returns
27
+ the value selected by the user. If the user closes the dialog box before selecting
28
+ an option, the default option is used.
29
+ :param prompt: The prompt string to display to the user.
30
+ :param options: A tuple of options (strings) to display to the user, which will
31
+ each get their own button. The last option is the default.
32
+ :return: The option that the user selected.
33
+ """
34
+ root = Tk()
35
+ root.title('Bond Reconciliation')
36
+ dialog = OptionDialog(root, prompt, options)
37
+ dialog.mainloop()
38
+ try:
39
+ root.destroy()
40
+ except TclError:
41
+ pass # Probably already destroyed, just ignore
42
+ return dialog.last_button
43
+
44
+ def _create_widgets(self, prompt, options):
45
+
46
+ def fill_last_button(button_text):
47
+ self.last_button = button_text
48
+ self.quit()
49
+
50
+ num_cols = max(50, max(map(lambda line: len(line), prompt.split('\n'))))
51
+ num_rows = prompt.count('\n') + 2
52
+
53
+ textbox = ScrolledText(self, relief='flat', padx='8', pady='5',
54
+ height=num_rows, width=num_cols)
55
+ textbox.insert(INSERT, prompt)
56
+ textbox['state'] = DISABLED
57
+ textbox.pack(side='top')
58
+
59
+ for option in reversed(options):
60
+ opt_button = Button(self,
61
+ text=option,
62
+ command=functools.partial(fill_last_button, option),
63
+ default='active' if option == options[-1] else 'normal')
64
+ opt_button.pack(side='right')
65
+
66
+ def _center(self, master):
67
+ master.update_idletasks()
68
+ screen_width = master.winfo_screenwidth()
69
+ screen_height = master.winfo_screenheight()
70
+ size_x, size_y = tuple(int(_) for _ in master.geometry().split('+')[0].split('x'))
71
+ x = screen_width/2 - size_x/2
72
+ y = screen_height/2 - size_y/2
73
+ master.geometry("{}x{}+{}+{}".format(size_x, size_y, x, y))
@@ -3,7 +3,7 @@ require_relative 'lib/bond/version'
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'bond-spy'
5
5
  spec.version = Bond::VERSION
6
- spec.date = '2016-02-04'
6
+ spec.date = '2016-02-18'
7
7
 
8
8
  spec.authors = ['George Necula', 'Erik Krogen']
9
9
  spec.email = ['necula@cs.berkeley.edu', 'erikkrogen@gmail.com']
@@ -232,6 +232,7 @@ class Bond
232
232
  # has already been JSON-serialized and outputs them all as a JSON array.
233
233
  # @param fname [String] Path where the file should be saved.
234
234
  def save_observations(fname)
235
+ FileUtils.mkdir_p(File.dirname(fname))
235
236
  File.open(fname, 'w') do |f|
236
237
  f.print("[\n#{@observations.join(",\n")}\n]\n")
237
238
  end
@@ -26,7 +26,7 @@ shared_context :bond do |**settings|
26
26
 
27
27
  after :each do
28
28
  if bond.send(:finish_test) == :bond_fail
29
- fail('BOND_FAIL. Pass BOND_RECONCILE=[kdiff3|console|accept] environment variable to reconcile the observations.')
29
+ fail('BOND_FAIL. Pass BOND_RECONCILE=[kdiff3|console|dialog|accept] environment variable to reconcile the observations.')
30
30
  end
31
31
  end
32
32
  end
@@ -1,3 +1,3 @@
1
1
  class Bond
2
- VERSION = '0.2.0'
2
+ VERSION = '0.2.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bond-spy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - George Necula
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-02-04 00:00:00.000000000 Z
12
+ date: 2016-02-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: neatjson
@@ -93,6 +93,7 @@ files:
93
93
  - LICENSE
94
94
  - README.rst
95
95
  - Rakefile
96
+ - bin/bond_dialog.py
96
97
  - bin/bond_reconcile.py
97
98
  - bin/setup
98
99
  - bond.gemspec