Skip to content
This repository has been archived by the owner on Jan 6, 2021. It is now read-only.

Commit

Permalink
Merge pull request #17 from IceDynamix/open-output-folder-in-explorer
Browse files Browse the repository at this point in the history
Open output folder in explorer after conversion
  • Loading branch information
IceDynamix authored Feb 27, 2020
2 parents 42b8c5f + c2539eb commit 5dd9a95
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 26 deletions.
64 changes: 39 additions & 25 deletions docs/qua2osu-gui.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@
<div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">os</span>
<span class="kn">import</span> <span class="nn">sys</span>
<span class="kn">import</span> <span class="nn">time</span>
<span class="kn">import</span> <span class="nn">webbrowser</span> <span class="c1"># to open the explorer cross-platform</span>

<span class="kn">from</span> <span class="nn">PyQt5.QtCore</span> <span class="kn">import</span> <span class="o">*</span>
<span class="kn">from</span> <span class="nn">PyQt5.QtGui</span> <span class="kn">import</span> <span class="o">*</span>
<span class="kn">from</span> <span class="nn">PyQt5.QtWidgets</span> <span class="kn">import</span> <span class="o">*</span>

<span class="kn">from</span> <span class="nn">convert</span> <span class="kn">import</span> <span class="n">convertMapset</span></pre></div>
<span class="kn">from</span> <span class="nn">conversion</span> <span class="kn">import</span> <span class="n">convertMapset</span></pre></div>
</div>
</div>
<div class='clearall'></div>
Expand Down Expand Up @@ -409,30 +410,28 @@
<span class="bp">self</span><span class="o">.</span><span class="n">updateStatus</span><span class="o">.</span><span class="n">emit</span><span class="p">(</span><span class="s2">&quot;No mapsets found in &quot;</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">inputPath</span><span class="p">)</span>
<span class="k">return</span>

<span class="k">else</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">updateProgressbarMax</span><span class="o">.</span><span class="n">emit</span><span class="p">(</span><span class="n">numberOfQpFiles</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">updateProgressbarMax</span><span class="o">.</span><span class="n">emit</span><span class="p">(</span><span class="n">numberOfQpFiles</span><span class="p">)</span>

<span class="n">start</span> <span class="o">=</span> <span class="n">time</span><span class="o">.</span><span class="n">time</span><span class="p">()</span>
<span class="n">count</span> <span class="o">=</span> <span class="mi">1</span>
<span class="k">for</span> <span class="n">file</span> <span class="ow">in</span> <span class="n">qpFilesInInputDir</span><span class="p">:</span>
<span class="n">filePath</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">inputPath</span><span class="p">,</span> <span class="n">file</span><span class="p">)</span>
<span class="n">start</span> <span class="o">=</span> <span class="n">time</span><span class="o">.</span><span class="n">time</span><span class="p">()</span>
<span class="n">count</span> <span class="o">=</span> <span class="mi">1</span>

<span class="bp">self</span><span class="o">.</span><span class="n">updateStatus</span><span class="o">.</span><span class="n">emit</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;(</span><span class="si">{count}</span><span class="s2">/</span><span class="si">{numberOfQpFiles}</span><span class="s2">) &quot;</span>
<span class="sa">f</span><span class="s2">&quot;Converting </span><span class="si">{filePath}</span><span class="s2">&quot;</span><span class="p">)</span>
<span class="k">for</span> <span class="n">file</span> <span class="ow">in</span> <span class="n">qpFilesInInputDir</span><span class="p">:</span>
<span class="n">filePath</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">inputPath</span><span class="p">,</span> <span class="n">file</span><span class="p">)</span>

<span class="n">convertMapset</span><span class="p">(</span><span class="n">filePath</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">outputPath</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">options</span><span class="p">)</span>
<span class="n">count</span> <span class="o">+=</span> <span class="mi">1</span>
<span class="bp">self</span><span class="o">.</span><span class="n">incrementProgressbarValue</span><span class="o">.</span><span class="n">emit</span><span class="p">()</span>
<span class="bp">self</span><span class="o">.</span><span class="n">updateStatus</span><span class="o">.</span><span class="n">emit</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;(</span><span class="si">{count}</span><span class="s2">/</span><span class="si">{numberOfQpFiles}</span><span class="s2">) &quot;</span>
<span class="sa">f</span><span class="s2">&quot;Converting </span><span class="si">{filePath}</span><span class="s2">&quot;</span><span class="p">)</span>

<span class="n">end</span> <span class="o">=</span> <span class="n">time</span><span class="o">.</span><span class="n">time</span><span class="p">()</span>
<span class="n">timeElapsed</span> <span class="o">=</span> <span class="nb">round</span><span class="p">(</span><span class="n">end</span> <span class="o">-</span> <span class="n">start</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
<span class="n">convertMapset</span><span class="p">(</span><span class="n">filePath</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">outputPath</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">options</span><span class="p">)</span>
<span class="n">count</span> <span class="o">+=</span> <span class="mi">1</span>
<span class="bp">self</span><span class="o">.</span><span class="n">incrementProgressbarValue</span><span class="o">.</span><span class="n">emit</span><span class="p">()</span>

<span class="bp">self</span><span class="o">.</span><span class="n">updateStatus</span><span class="o">.</span><span class="n">emit</span><span class="p">(</span>
<span class="sa">f</span><span class="s2">&quot;Finished converting all mapsets,&quot;</span>
<span class="sa">f</span><span class="s2">&quot;total time elapsed: </span><span class="si">{timeElapsed}</span><span class="s2"> seconds&quot;</span>
<span class="p">)</span>
<span class="n">end</span> <span class="o">=</span> <span class="n">time</span><span class="o">.</span><span class="n">time</span><span class="p">()</span>
<span class="n">timeElapsed</span> <span class="o">=</span> <span class="nb">round</span><span class="p">(</span><span class="n">end</span> <span class="o">-</span> <span class="n">start</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>

<span class="k">return</span></pre></div>
<span class="bp">self</span><span class="o">.</span><span class="n">updateStatus</span><span class="o">.</span><span class="n">emit</span><span class="p">(</span>
<span class="sa">f</span><span class="s2">&quot;Finished converting all mapsets,&quot;</span>
<span class="sa">f</span><span class="s2">&quot;total time elapsed: </span><span class="si">{timeElapsed}</span><span class="s2"> seconds&quot;</span>
<span class="p">)</span></pre></div>
</div>
</div>
<div class='clearall'></div>
Expand All @@ -441,10 +440,13 @@
<div class='octowrap'>
<a class='octothorpe' href='#section-26'>#</a>
</div>
<p>Custom QApplication class for the sole purpose of applying the Fusion style</p>
<p>Opens output folder in explorer</p>
</div>
<div class='code'>
<div class="highlight"><pre><span class="k">class</span> <span class="nc">IceApp</span><span class="p">(</span><span class="n">QApplication</span><span class="p">):</span></pre></div>
<div class="highlight"><pre> <span class="n">absoluteOutputPath</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">realpath</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">inputPath</span><span class="p">)</span>
<span class="n">webbrowser</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="s2">&quot;file:///&quot;</span> <span class="o">+</span> <span class="n">absoluteOutputPath</span><span class="p">)</span>

<span class="k">return</span></pre></div>
</div>
</div>
<div class='clearall'></div>
Expand All @@ -453,10 +455,10 @@
<div class='octowrap'>
<a class='octothorpe' href='#section-27'>#</a>
</div>

<p>Custom QApplication class for the sole purpose of applying the Fusion style</p>
</div>
<div class='code'>
<div class="highlight"><pre></pre></div>
<div class="highlight"><pre><span class="k">class</span> <span class="nc">IceApp</span><span class="p">(</span><span class="n">QApplication</span><span class="p">):</span></pre></div>
</div>
</div>
<div class='clearall'></div>
Expand All @@ -466,6 +468,18 @@
<a class='octothorpe' href='#section-28'>#</a>
</div>

</div>
<div class='code'>
<div class="highlight"><pre></pre></div>
</div>
</div>
<div class='clearall'></div>
<div class='section' id='section-29'>
<div class='docs'>
<div class='octowrap'>
<a class='octothorpe' href='#section-29'>#</a>
</div>

</div>
<div class='code'>
<div class="highlight"><pre> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
Expand All @@ -474,10 +488,10 @@
</div>
</div>
<div class='clearall'></div>
<div class='section' id='section-29'>
<div class='section' id='section-30'>
<div class='docs'>
<div class='octowrap'>
<a class='octothorpe' href='#section-29'>#</a>
<a class='octothorpe' href='#section-30'>#</a>
</div>

</div>
Expand Down
16 changes: 15 additions & 1 deletion docs/qua2osu.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ <h2>Imports</h2>
<span class="kn">import</span> <span class="nn">os</span> <span class="c1"># for paths and directories</span>
<span class="kn">import</span> <span class="nn">sys</span> <span class="c1"># used only for sys.exit()</span>
<span class="kn">import</span> <span class="nn">time</span> <span class="c1"># to measure execution time</span>
<span class="kn">import</span> <span class="nn">webbrowser</span> <span class="c1"># to open the explorer cross-platform</span>

<span class="kn">from</span> <span class="nn">constants</span> <span class="kn">import</span> <span class="o">*</span>
<span class="kn">from</span> <span class="nn">conversion</span> <span class="kn">import</span> <span class="n">convertMapset</span></pre></div>
Expand Down Expand Up @@ -346,7 +347,20 @@ <h3>Main</h3>
<span class="n">timeElapsed</span> <span class="o">=</span> <span class="nb">round</span><span class="p">(</span><span class="n">end</span> <span class="o">-</span> <span class="n">start</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>

<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Finished converting all mapsets, &quot;</span>
<span class="sa">f</span><span class="s2">&quot;total time elapsed: </span><span class="si">{timeElapsed}</span><span class="s2"> seconds&quot;</span><span class="p">)</span>
<span class="sa">f</span><span class="s2">&quot;total time elapsed: </span><span class="si">{timeElapsed}</span><span class="s2"> seconds&quot;</span><span class="p">)</span></pre></div>
</div>
</div>
<div class='clearall'></div>
<div class='section' id='section-21'>
<div class='docs'>
<div class='octowrap'>
<a class='octothorpe' href='#section-21'>#</a>
</div>
<p>Opens output folder in explorer</p>
</div>
<div class='code'>
<div class="highlight"><pre> <span class="n">absoluteOutputPath</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">realpath</span><span class="p">(</span><span class="n">args</span><span class="p">[</span><span class="s2">&quot;input&quot;</span><span class="p">])</span>
<span class="n">webbrowser</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="s2">&quot;file:///&quot;</span> <span class="o">+</span> <span class="n">absoluteOutputPath</span><span class="p">)</span>


<span class="k">if</span> <span class="vm">__name__</span> <span class="o">==</span> <span class="s1">&#39;__main__&#39;</span><span class="p">:</span>
Expand Down
5 changes: 5 additions & 0 deletions qua2osu-gui.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import sys
import time
import webbrowser # to open the explorer cross-platform

from PyQt5.QtCore import *
from PyQt5.QtGui import *
Expand Down Expand Up @@ -177,6 +178,10 @@ def run(self):
f"total time elapsed: {timeElapsed} seconds"
)

# Opens output folder in explorer
absoluteOutputPath = os.path.realpath(self.inputPath)
webbrowser.open("file:///" + absoluteOutputPath)

return


Expand Down
5 changes: 5 additions & 0 deletions qua2osu.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import os # for paths and directories
import sys # used only for sys.exit()
import time # to measure execution time
import webbrowser # to open the explorer cross-platform

from constants import *
from conversion import convertMapset
Expand Down Expand Up @@ -148,6 +149,10 @@ def main():
print("Finished converting all mapsets, "
f"total time elapsed: {timeElapsed} seconds")

# Opens output folder in explorer
absoluteOutputPath = os.path.realpath(args["input"])
webbrowser.open("file:///" + absoluteOutputPath)


if __name__ == '__main__':
main()
Expand Down

0 comments on commit 5dd9a95

Please sign in to comment.